質問編集履歴

2

文を少し変更しました

2019/12/10 08:07

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -30,7 +30,7 @@
30
30
 
31
31
 
32
32
 
33
- [Unity GL公式ページ](https://docs.unity3d.com/ja/2017.4/ScriptReference/GL.html) にあるCreateLineMaterial関数を下記に追記しました。
33
+ [Unity GL公式ページ](https://docs.unity3d.com/ja/2017.4/ScriptReference/GL.html)にあるCreateLineMaterial関数と同じ機能持った関数を下記に追記しました。
34
34
 
35
35
 
36
36
 

1

CreateLineMaterial関数の追加

2019/12/10 08:07

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -21,3 +21,63 @@
21
21
 
22
22
 
23
23
  質問の書き方が下手ですが、助けてくださるとうれしいです。
24
+
25
+
26
+
27
+ ---
28
+
29
+ ##追記事項
30
+
31
+
32
+
33
+ [Unity GL公式ページ](https://docs.unity3d.com/ja/2017.4/ScriptReference/GL.html) にあるCreateLineMaterial関数を下記に追記しました。
34
+
35
+
36
+
37
+ 下記の設定を行っても改善しませんでした。
38
+
39
+ また、ZWriteを1にするとGL平面が薄すぎるせいかうまく描画されませんでした。
40
+
41
+
42
+
43
+ ```C#
44
+
45
+ void CreateLineMaterial()
46
+
47
+ {
48
+
49
+ if (!lineMaterial)
50
+
51
+ {
52
+
53
+ // Unity has a built-in shader that is useful for drawing
54
+
55
+ // simple colored things.
56
+
57
+ Shader shader = Shader.Find("Hidden/Internal-Colored");
58
+
59
+ lineMaterial = new Material(shader);
60
+
61
+ lineMaterial.hideFlags = HideFlags.HideAndDontSave;
62
+
63
+ // Turn on alpha blending
64
+
65
+ lineMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
66
+
67
+ lineMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
68
+
69
+ // Turn backface culling off
70
+
71
+ lineMaterial.SetInt("_Cull", (int)UnityEngine.Rendering.CullMode.Off);
72
+
73
+ // Turn off depth writes
74
+
75
+ lineMaterial.SetInt("_ZWrite", 0);
76
+
77
+ lineMaterial.SetInt("_ZTest", (int)UnityEngine.Rendering.CompareFunction.Less);
78
+
79
+ }
80
+
81
+ }
82
+
83
+ ```