質問編集履歴

2

コードを少し直しました

2021/01/27 11:19

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  ```C#
16
16
 
17
- void Make2DMesh(GameObject Target)
17
+ void メソッド名(GameObject Target)
18
18
 
19
19
  {
20
20
 
@@ -32,25 +32,7 @@
32
32
 
33
33
  tris.AddRange(mesh.triangles);
34
34
 
35
- if (vertices.Count % 3 != 0)
36
-
37
- {
38
-
39
- Debug.Log("error");
40
-
41
- return;
42
-
43
- }
44
-
45
35
  vertices.AddRange(mesh.vertices);
46
-
47
- for (int i = 0; i < vertices.Count; i++)
48
-
49
- {
50
-
51
-
52
-
53
- }
54
36
 
55
37
  mesh.vertices = vertices.ToArray();
56
38
 

1

コードを載せました!

2021/01/27 11:19

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -14,16 +14,48 @@
14
14
 
15
15
  ```C#
16
16
 
17
- List<Vector3> vertices = new List<Vector3>();
17
+ void Make2DMesh(GameObject Target)
18
18
 
19
- vertices.AddRange(mesh.vertices);
19
+ {
20
20
 
21
- for (int i = 0; i < vertices.Count; i++)
21
+ //メッシュ
22
22
 
23
- {
23
+ Mesh mesh = Target.GetComponent<MeshFilter>().mesh;
24
24
 
25
-
25
+ //triangle
26
26
 
27
+ List<int> tris = new List<int>();
28
+
29
+ //頂点データ
30
+
31
+ List<Vector3> vertices = new List<Vector3>();
32
+
33
+ tris.AddRange(mesh.triangles);
34
+
35
+ if (vertices.Count % 3 != 0)
36
+
37
+ {
38
+
39
+ Debug.Log("error");
40
+
41
+ return;
42
+
27
- }
43
+ }
44
+
45
+ vertices.AddRange(mesh.vertices);
46
+
47
+ for (int i = 0; i < vertices.Count; i++)
48
+
49
+ {
50
+
51
+
52
+
53
+ }
54
+
55
+ mesh.vertices = vertices.ToArray();
56
+
57
+ Target.GetComponent<MeshFilter>().mesh = mesh;
58
+
59
+ }
28
60
 
29
61
  ```