質問編集履歴

5

説明追記

2020/02/15 15:28

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -182,7 +182,7 @@
182
182
 
183
183
  ```
184
184
 
185
- 「Sample」の文字が薄い。
185
+ 「Sample」の文字が薄い、もしくは、ぼやけている
186
186
 
187
187
  ![イメージ説明](79e3d1ca9bb0827fff4eeed365d377cc.png)
188
188
 

4

説明修正。

2020/02/15 15:28

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -174,7 +174,7 @@
174
174
 
175
175
 
176
176
 
177
- ・TransformPoint
177
+ ・TransformPointで設定した場合。
178
178
 
179
179
  ```C#
180
180
 

3

追記②

2020/02/15 15:26

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -153,3 +153,39 @@
153
153
  Assets\UISample.cs(21,34): error CS1061: 'Transform' does not contain a definition for 'pivot' and no accessible extension method 'pivot' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?)
154
154
 
155
155
  ```
156
+
157
+ ### 追記②
158
+
159
+
160
+
161
+ ・Screenで設定した場合。
162
+
163
+
164
+
165
+ ```C#
166
+
167
+ this.transform.position = new Vector2(Screen.width/2, Screen.height/2);
168
+
169
+ ```
170
+
171
+ 「Sample」の文字が濃い。
172
+
173
+ ![イメージ説明](fd774e98719bd84fdb200ac01d347cd4.png)
174
+
175
+
176
+
177
+ ・TransformPoint
178
+
179
+ ```C#
180
+
181
+ this.transform.position = this.transform.root.TransformPoint(Vector2.zero);
182
+
183
+ ```
184
+
185
+ 「Sample」の文字が薄い。
186
+
187
+ ![イメージ説明](79e3d1ca9bb0827fff4eeed365d377cc.png)
188
+
189
+
190
+
191
+ 両者の違いは上記コードだけです。他の設定は同じままです。

2

質問追記

2020/02/15 15:25

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -102,6 +102,54 @@
102
102
 
103
103
  [リファレンス](https://docs.unity3d.com/ja/current/ScriptReference/RectTransform.html)を見ましたが、transformはゲームオブジェクトにアタッチしているトランスフォームと書かれていて、これがRectTransformを指しているかどうかわかりませんでした。~~
104
104
 
105
- →this.transformは、RectTransformのよでし(間違っらご指摘お願います)
105
+ 上記調べていくちに新な疑問が出きまし。詳細は追記質問に書きま
106
+
107
+
106
108
 
107
109
  試したこと以外にも、何かおすすめの位置設定方法があれば教えていただきたいです。
110
+
111
+
112
+
113
+ ### 追記質問
114
+
115
+
116
+
117
+ this.transformはRectTransformを本当に取得できているのかどうかわかりません。
118
+
119
+ RectTransformを取得できているはずなのに、pivotを取得しようとするとエラーになってしまうのは何故なのでしょうか?
120
+
121
+ ```C#
122
+
123
+ [SerializeField]
124
+
125
+ RectTransform rectTransform;
126
+
127
+
128
+
129
+ void Start()
130
+
131
+ {
132
+
133
+ Debug.Log(this.transform); // Text (UnityEngine.RectTransform)
134
+
135
+ Debug.Log(this.rectTransform); // Text (UnityEngine.RectTransform)
136
+
137
+ Debug.Log(this.transform == this.rectTransform); // True
138
+
139
+ Debug.Log(this.transform.pivot); // ※ エラー。
140
+
141
+ Debug.Log(this.rectTransform.pivot); // (0.5, 0.5);
142
+
143
+ }
144
+
145
+ ```
146
+
147
+
148
+
149
+ エラーメッセージ。
150
+
151
+ ```
152
+
153
+ Assets\UISample.cs(21,34): error CS1061: 'Transform' does not contain a definition for 'pivot' and no accessible extension method 'pivot' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?)
154
+
155
+ ```

1

追記

2020/02/09 06:54

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -98,8 +98,10 @@
98
98
 
99
99
  localPositionだけでなく、positionもピボットの位置によって、基準位置が設定されているということでしょうか?
100
100
 
101
- また、UI Textにアタッチしているスクリプトにおけるthis.transformは、UI TextのRectTransformを参照できていることでしょうか?
101
+ ~~また、UI Textにアタッチしているスクリプトにおけるthis.transformは、UI TextのRectTransformを参照できていることでしょうか?
102
102
 
103
- [リファレンス](https://docs.unity3d.com/ja/current/ScriptReference/RectTransform.html)を見ましたが、transformはゲームオブジェクトにアタッチしているトランスフォームと書かれていて、これがRectTransformを指しているかどうかわかりませんでした。
103
+ [リファレンス](https://docs.unity3d.com/ja/current/ScriptReference/RectTransform.html)を見ましたが、transformはゲームオブジェクトにアタッチしているトランスフォームと書かれていて、これがRectTransformを指しているかどうかわかりませんでした。~~
104
+
105
+ →this.transformは、RectTransformのようでした(間違っていたらご指摘お願いします)。
104
106
 
105
107
  試したこと以外にも、何かおすすめの位置設定方法があれば教えていただきたいです。