Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
HorizonWithSunSkyboxInspector.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 HorizonWithSunSkyboxInspector : MaterialEditor {
7  public override void OnInspectorGUI() {
8  this.serializedObject.Update();
9 
10  if (this.isVisible) {
11  EditorGUI.BeginChangeCheck();
12 
13  GUILayout.Label("Background Parameters");
14 
15  EditorGUILayout.Space();
16 
17  this.ColorProperty(GetMaterialProperty(this.targets, "_SkyColor1"), "Top Color");
18  this.FloatProperty(GetMaterialProperty(this.targets, "_SkyExponent1"), "Exponential Factor");
19 
20  EditorGUILayout.Space();
21 
22  this.ColorProperty(GetMaterialProperty(this.targets, "_SkyColor2"), "Horizon Color");
23 
24  EditorGUILayout.Space();
25 
26  this.ColorProperty(GetMaterialProperty(this.targets, "_SkyColor3"), "Bottom Color");
27  this.FloatProperty(GetMaterialProperty(this.targets, "_SkyExponent2"), "Exponential Factor");
28 
29  EditorGUILayout.Space();
30 
31  this.FloatProperty(GetMaterialProperty(this.targets, "_SkyIntensity"), "Intensity");
32 
33  EditorGUILayout.Space();
34 
35  GUILayout.Label("Sun Parameters");
36 
37  EditorGUILayout.Space();
38 
39  this.ColorProperty(GetMaterialProperty(this.targets, "_SunColor"), "Color");
40  this.FloatProperty(GetMaterialProperty(this.targets, "_SunIntensity"), "Intensity");
41 
42  EditorGUILayout.Space();
43 
44  this.FloatProperty(GetMaterialProperty(this.targets, "_SunAlpha"), "Alpha");
45  this.FloatProperty(GetMaterialProperty(this.targets, "_SunBeta"), "Beta");
46 
47  EditorGUILayout.Space();
48 
49  var az = GetMaterialProperty(this.targets, "_SunAzimuth");
50  var al = GetMaterialProperty(this.targets, "_SunAltitude");
51 
52  if (az.hasMixedValue || al.hasMixedValue) {
53  EditorGUILayout.HelpBox("Editing angles is disabled because they have mixed values.",
54  MessageType.Warning);
55  } else {
56  this.FloatProperty(az, "Azimuth");
57  this.FloatProperty(al, "Altitude");
58  }
59 
60  if (EditorGUI.EndChangeCheck()) {
61  var raz = az.floatValue * Mathf.Deg2Rad;
62  var ral = al.floatValue * Mathf.Deg2Rad;
63 
64  var up_vector = new Vector4(Mathf.Cos(ral) * Mathf.Sin(raz),
65  Mathf.Sin(ral),
66  Mathf.Cos(ral) * Mathf.Cos(raz),
67  0.0f);
68  GetMaterialProperty(this.targets, "_SunVector").vectorValue = up_vector;
69 
70  this.PropertiesChanged();
71  }
72  }
73  }
74  }
75 }
76 #endif