質問編集履歴
4
編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
imageをカットして保存したいのですが,リサイズする時にエラーになります。
|
4
4
|
サイズ変換に渡しているTexture2Dがセットされていない?
|
5
5
|

|
6
|
+

|
6
7
|
### 発生している問題・エラーメッセージ
|
7
8
|
|
8
9
|
```
|
3
編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
|
3
3
|
imageをカットして保存したいのですが,リサイズする時にエラーになります。
|
4
4
|
サイズ変換に渡しているTexture2Dがセットされていない?
|
5
|
-

|
6
|
-
|
7
|
-

|
8
6
|
### 発生している問題・エラーメッセージ
|
9
7
|
|
10
8
|
```
|
2
編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
imageをカットして保存したいのですが,リサイズする時にエラーになります。
|
4
4
|
サイズ変換に渡しているTexture2Dがセットされていない?
|
5
|
+

|
5
6
|
|
6
|
-
|
7
7
|

|
8
8
|
### 発生している問題・エラーメッセージ
|
9
9
|
|
1
編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,25 +8,16 @@
|
|
8
8
|
### 発生している問題・エラーメッセージ
|
9
9
|
|
10
10
|
```
|
11
|
-
MissingComponentException:There is no '
|
11
|
+
MissingComponentException: There is no 'SpriteRenderer' attached to the "Puzzle" game object,but a script is trying to access it. というエラーが表示されます。
|
12
|
-
|
13
12
|
```
|
14
13
|
|
15
14
|
### 該当のソースコード
|
16
15
|
|
17
16
|
```Unity 2018.2.5f1
|
18
17
|
|
19
|
-
|
18
|
+
GameObject imge_object = GameObject.Find("Puzzle");
|
20
|
-
|
19
|
+
texture2D = imge_object.GetComponent<SpriteRenderer>().sprite.texture;
|
21
|
-
|
20
|
+
//保存する画像のサイズを帰
|
22
|
-
|
21
|
+
texture2D = ResizeTexture(texture2D, 320, 320);
|
23
|
-
- - -
|
24
|
-
Texture2D ResizeTexture(Texture2D src, int dst_w, int dst_h)
|
25
|
-
{
|
26
|
-
Texture2D dst = new Texture2D(dst_w, dst_h, src.format, false); <---- この行でエラーになります。
|
27
22
|
|
28
|
-
float inv_w = 1f / dst_w;
|
29
|
-
float inv_h = 1f / dst_h;
|
30
|
-
return dst;
|
31
|
-
}
|
32
23
|
```
|