teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

編集

2019/12/09 20:44

投稿

tamachan2020
tamachan2020

スコア31

title CHANGED
File without changes
body CHANGED
@@ -3,6 +3,7 @@
3
3
  imageをカットして保存したいのですが,リサイズする時にエラーになります。
4
4
  サイズ変換に渡しているTexture2Dがセットされていない?
5
5
  ![イメージ説明](818e6beab77962a300cb5fd6ab14737f.png)
6
+ ![イメージ説明](78745e3754f05583fbc73a08b431736a.png)
6
7
  ### 発生している問題・エラーメッセージ
7
8
 
8
9
  ```

3

編集

2019/12/09 20:44

投稿

tamachan2020
tamachan2020

スコア31

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

2

編集

2019/12/09 10:45

投稿

tamachan2020
tamachan2020

スコア31

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

1

編集

2019/12/09 10:38

投稿

tamachan2020
tamachan2020

スコア31

title CHANGED
File without changes
body CHANGED
@@ -8,25 +8,16 @@
8
8
  ### 発生している問題・エラーメッセージ
9
9
 
10
10
  ```
11
- MissingComponentException:There is no 'Texture2S' attached to the "Puzzle" game object,but a script is trying to access it.
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
- GameObject imge_object = GameObject.Find("Puzzle");
18
+ GameObject imge_object = GameObject.Find("Puzzle");
20
- texture2D = imge_object.GetComponent<Texture2D>();
19
+ texture2D = imge_object.GetComponent<SpriteRenderer>().sprite.texture;
21
- //保存する画像のサイズを帰
20
+ //保存する画像のサイズを帰
22
- texture2D = ResizeTexture(texture2D, 320, 320);
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
  ```