Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
GradientSkyboxInspector.cs
Go to the documentation of this file.
1 using UnityEngine;
2 #if UNITY_EDITOR
3 using UnityEditor;
4 
5 namespace droid.Runtime.Shaders.Experimental.Skybox_Shaders.Editor {
6  public class GradientSkyboxInspector : MaterialEditor {
7  public override void OnInspectorGUI() {
8  this.serializedObject.Update();
9 
10  if (this.isVisible) {
11  EditorGUI.BeginChangeCheck();
12 
13  this.ColorProperty(GetMaterialProperty(this.targets, "_Color2"), "Top Color");
14  this.ColorProperty(GetMaterialProperty(this.targets, "_Color1"), "Bottom Color");
15  this.FloatProperty(GetMaterialProperty(this.targets, "_Intensity"), "Intensity");
16  this.FloatProperty(GetMaterialProperty(this.targets, "_Exponent"), "Exponent");
17 
18  var dp = GetMaterialProperty(this.targets, "_UpVectorPitch");
19  var dy = GetMaterialProperty(this.targets, "_UpVectorYaw");
20 
21  if (dp.hasMixedValue || dy.hasMixedValue) {
22  EditorGUILayout.HelpBox("Editing angles is disabled because they have mixed values.",
23  MessageType.Warning);
24  } else {
25  this.FloatProperty(dp, "Pitch");
26  this.FloatProperty(dy, "Yaw");
27  }
28 
29  if (EditorGUI.EndChangeCheck()) {
30  var rp = dp.floatValue * Mathf.Deg2Rad;
31  var ry = dy.floatValue * Mathf.Deg2Rad;
32 
33  var up_vector = new Vector4(Mathf.Sin(rp) * Mathf.Sin(ry),
34  Mathf.Cos(rp),
35  Mathf.Sin(rp) * Mathf.Cos(ry),
36  0.0f);
37  GetMaterialProperty(this.targets, "_UpVector").vectorValue = up_vector;
38 
39  this.PropertiesChanged();
40  }
41  }
42  }
43  }
44 }
45 #endif