public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUI.BeginChangeCheck();

            //Sync inspector var to static class var
            visualizeVectors = WindController._visualizeVectors;

            Undo.RecordObject(this, "Component");
            Undo.RecordObject(wc, "WindController");

            DrawFields();

            serializedObject.ApplyModifiedProperties();

            if (GUI.changed || EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty((WindController)target);
                wc.Apply();

                //Set the static var
                WindController.VisualizeVectors(visualizeVectors);
            }
        }
Esempio n. 2
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            if (windController == null)
            {
                LocateWindController();
            }
            this.FindProperties(props);

            //Receive
            visualizeVectors = WindController._visualizeVectors;

            this.m_MaterialEditor = materialEditor;

            //Style similar to Standard shader
            m_MaterialEditor.SetDefaultGUIWidths();
            m_MaterialEditor.UseDefaultMargins();
            EditorGUIUtility.labelWidth = 0f;

            //GetGlobalTexture is only available since Unity 5.5
#if UNITY_5_5_OR_NEWER
            hasPigmentMap = (Shader.GetGlobalTexture("_PigmentMap")) ? true : false;
#endif

            EditorGUI.BeginChangeCheck();

            //Draw fields
            DoHeader();

            DoMapsArea();
            DoColorArea();
            DoAnimationArea();
            DoHeightmapArea();
            DoPigmentMapArea();

            if (EditorGUI.EndChangeCheck())
            {
                //Send
                WindController.VisualizeVectors(visualizeVectors);
            }

#if UNITY_5_5_OR_NEWER
            m_MaterialEditor.RenderQueueField();
#endif

#if UNITY_5_6_OR_NEWER
            m_MaterialEditor.EnableInstancingField();
#endif

            DoFooter();
        }
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            if (windController == null)
            {
                LocateWindController();
            }

            //Receive
            visualizeVectors = WindController._visualizeVectors;

            this.m_MaterialEditor = materialEditor;
            targetMat             = (Material)materialEditor.target;

            this.FindProperties(props);

            //Style similar to Standard shader
            m_MaterialEditor.SetDefaultGUIWidths();
            m_MaterialEditor.UseDefaultMargins();
            EditorGUIUtility.labelWidth = 0f;

#if UNITY_2019_3_OR_NEWER
            if (UnityEngine.Rendering.GraphicsSettings.currentRenderPipeline != null &&
                !targetMat.shader.name.Contains("Universal Render Pipeline"))
            {
                EditorGUILayout.HelpBox("A render pipeline is in use, but this material is using a shader for the Built-in render pipeline.\n\nShaders and materials can be converted through the Help window", MessageType.Error);
                EditorGUILayout.Space();
            }
#endif

            EditorGUI.BeginChangeCheck();

            //Draw fields
            DoHeader();

            DoMapsArea();
            DoColorArea();
            DoAnimationArea();

            if (EditorGUI.EndChangeCheck())
            {
                //Send
                WindController.VisualizeVectors(visualizeVectors);
            }

            GUILayout.Label("Advanced Options", EditorStyles.boldLabel);

            GUIHelper.DrawExtraFields(m_MaterialEditor);

            GUIHelper.DrawFooter();
        }
Esempio n. 4
0
        private static void NewMenuOption()
        {
            WindController currentWindController = GameObject.FindObjectOfType <WindController>();

            if (currentWindController != null)
            {
                if (EditorUtility.DisplayDialog("FAE Wind Controller", "A WindController object already exists in your scene", "Create anyway", "Cancel"))
                {
                    CreateNewWindController();
                }
            }
            else
            {
                CreateNewWindController();
            }
        }
        void OnEnable()
        {
            wc = (WindController)target;
            serializedObject = new SerializedObject(target);
            listenToWindZone = serializedObject.FindProperty("listenToWindZone");
            windZone         = serializedObject.FindProperty("windZone");
            windVectors      = serializedObject.FindProperty("windVectors");

            windSpeed     = serializedObject.FindProperty("windSpeed");
            windStrength  = serializedObject.FindProperty("windStrength");
            windAmplitude = serializedObject.FindProperty("windAmplitude");

            trunkWindSpeed    = serializedObject.FindProperty("trunkWindSpeed");
            trunkWindWeight   = serializedObject.FindProperty("trunkWindWeight");
            trunkWindSwinging = serializedObject.FindProperty("trunkWindSwinging");
        }
Esempio n. 6
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            if (windController == null)
            {
                LocateWindController();
            }
            this.FindProperties(props);

            //Receive
            visualizeVectors = WindController._visualizeVectors;

            this.m_MaterialEditor = materialEditor;

            //Style similar to Standard shader
            m_MaterialEditor.SetDefaultGUIWidths();
            m_MaterialEditor.UseDefaultMargins();
            EditorGUIUtility.labelWidth = 0f;

            EditorGUI.BeginChangeCheck();

            //Draw fields
            DoHeader();

            DoMapsArea();
            DoColorArea();
            DoAnimationArea();

            if (EditorGUI.EndChangeCheck())
            {
                //Send
                WindController.VisualizeVectors(visualizeVectors);
            }

            GUILayout.Label("Advanced Options", EditorStyles.boldLabel);

            GUIHelper.DrawExtraFields(m_MaterialEditor);

            EditorGUI.BeginDisabledGroup(_UseSpeedTreeWind.floatValue == 1);
            m_MaterialEditor.ShaderProperty(_UseLegacyVertexColors, new GUIContent("Legacy vertex color layout"));
            if (_UseSpeedTreeWind.floatValue == 0)
            {
                EditorGUILayout.HelpBox("Since version 1.2.1 the Blue and Alpha channel have been swapped. If your custom tree uses the old layout, check this.", MessageType.None);
            }
            EditorGUI.EndDisabledGroup();

            GUIHelper.DrawFooter();
        }
Esempio n. 7
0
        void OnEnable()
        {
            selection = Selection.activeGameObject;
            if (selection)
            {
                wc = Selection.activeGameObject.GetComponent <WindController>();
            }

            serializedObject = new SerializedObject(wc);
            windSubstance    = serializedObject.FindProperty("windSubstance");
            windVectors      = serializedObject.FindProperty("windVectors");

            windDirection = serializedObject.FindProperty("windDirection");
            windSpeed     = serializedObject.FindProperty("windSpeed");
            windStrength  = serializedObject.FindProperty("windStrength");
            windAmplitude = serializedObject.FindProperty("windAmplitude");

            trunkWindSpeed    = serializedObject.FindProperty("trunkWindSpeed");
            trunkWindWeight   = serializedObject.FindProperty("trunkWindWeight");
            trunkWindSwinging = serializedObject.FindProperty("trunkWindSwinging");
        }
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            if (windController == null)
            {
                LocateWindController();
            }
            this.FindProperties(props);

            //Receive
            visualizeVectors = WindController._visualizeVectors;

            this.m_MaterialEditor = materialEditor;

            //Style similar to Standard shader
            m_MaterialEditor.SetDefaultGUIWidths();
            m_MaterialEditor.UseDefaultMargins();
            EditorGUIUtility.labelWidth = 0f;

            EditorGUI.BeginChangeCheck();

            //Draw fields
            DoHeader();

            DoMapsArea();
            DoColorArea();
            DoAnimationArea();

            if (EditorGUI.EndChangeCheck())
            {
                //Send
                WindController.VisualizeVectors(visualizeVectors);
            }

            GUILayout.Label("Advanced Options", EditorStyles.boldLabel);

            GUIHelper.DrawExtraFields(m_MaterialEditor);

            GUIHelper.DrawFooter();
        }
Esempio n. 9
0
 void LocateWindController()
 {
     //Debug.Log("Searching scene for WindController script");
     windController    = GameObject.FindObjectOfType <WindController>();
     hasWindController = (windController) ? true : false;
 }