Example #1
0
        void SetMaterialSettings()
        {
            int length = allMaterialGUIDs.Length;
            int count  = 0;

            foreach (var asset in allMaterialGUIDs)
            {
                var path    = AssetDatabase.GUIDToAssetPath(asset);
                var message = "Checking ";

                if (path.Contains("TVE Material"))
                {
                    var material = AssetDatabase.LoadAssetAtPath <Material>(path);
                    TVEShaderUtils.SetMaterialSettings(material);
                }

                EditorUtility.DisplayProgressBar("The Vegetatin Engine", message + Path.GetFileName(path), (float)count * (1.0f / (float)length));
            }

            EditorUtility.ClearProgressBar();
        }
Example #2
0
        void UpgradeAsset()
        {
            if (userVersion < 200)
            {
                int length = allMaterialGUIDs.Length;
                int count  = 0;

                foreach (var asset in allMaterialGUIDs)
                {
                    var path    = AssetDatabase.GUIDToAssetPath(asset);
                    var message = "Checking ";

                    if (path.Contains("TVE Material"))
                    {
                        var material = AssetDatabase.LoadAssetAtPath <Material>(path);
                        TVEShaderUtils.UpgradeMaterialTo200(material);
                        TVEShaderUtils.SetMaterialSettings(material);
                        message = "Upgrading ";
                    }
                    else if (path.Contains("TVE Element"))
                    {
                        var material = AssetDatabase.LoadAssetAtPath <Material>(path);
                        TVEShaderUtils.UpgradeElementTo200(material);
                        message = "Upgrading ";
                    }

                    EditorUtility.DisplayProgressBar("The Vegetatin Engine", message + Path.GetFileName(path), (float)count * (1.0f / (float)length));

                    count++;
                }

                EditorUtility.ClearProgressBar();
            }

            Debug.Log("[The Vegetation Engine] " + "The Vegetation Engine materials have been upgraded to version " + bannerVersion);
        }
Example #3
0
        void OnGUI()
        {
            SetGUIStyles();

            GUI_HALF_WIDTH = this.position.width / 2.0f - 24;

            StyledGUI.DrawWindowBanner(bannerColor, bannerText, helpURL);

            GUILayout.BeginHorizontal();
            GUILayout.Space(15);

            GUILayout.BeginVertical();

            GUILayout.Space(-2);

            if (isValid && prefabObjects.Count > 0)
            {
                EditorGUILayout.HelpBox("Move the slider to owerride the Mixed values for prefabs with different material settings. Please note that Undo is not supported for the Prefab Settings window!", MessageType.Info, true);

                if (useProceduralVariation)
                {
                    EditorGUILayout.HelpBox("Procedural variation detected! Use the Scale settings if the Variation is breaking the bending and rolling animation!", MessageType.Warning, true);
                }
            }
            else
            {
                if (isValid == false)
                {
                    EditorGUILayout.HelpBox("The Vegetation Engine manager is missing from your scene. Make sure setup it up first and the reopen the Prefab Converter!", MessageType.Warning, true);
                }
                else if (prefabObjects.Count == 0)
                {
                    EditorGUILayout.HelpBox("Select a prefab or multiple prefabs to get started!", MessageType.Info, true);
                }
            }

            scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false, GUILayout.Width(this.position.width - 28), GUILayout.Height(this.position.height - 200));

            if (isValid == false || prefabObjects.Count == 0)
            {
                GUI.enabled = false;
            }

            DrawWindPower();

            SetGlobalShaderProperties();

            if (TVEManager.Instance == null)
            {
                globalMotion = TVEManager.Instance.globalMotion;
            }

            if (prefabObjects.Count > 0)
            {
                GUILayout.Space(5);
            }

            DrawPrefabObjects();

            GUILayout.Space(15);

            presetIndex = StyledPopup("Material Preset", presetIndex, presetOptions);

            if (presetIndex > 0)
            {
                GetPresetLines();

                for (int i = 0; i < prefabMaterials.Count; i++)
                {
                    var material = prefabMaterials[i];

                    GetMaterialConversionFromPreset(material);
                    TVEShaderUtils.SetMaterialSettings(material);
                }

                materialData = new List <TVEMaterialData>();
                materialData.AddRange(motionData);
                materialData.AddRange(globalData);
                materialData.AddRange(subsurfaceData);
                materialData.AddRange(mainData);
                materialData.AddRange(secondData);
                materialData.AddRange(gradientAndNoiseData);
                materialData.AddRange(billboardAndGrassData);

                GetInitMaterialProperties();
                GetMaterialProperties();

                presetIndex      = 0;
                settingsIndexOld = -1;
            }

            settingsIndex = StyledPopup("Material Settings", settingsIndex, materialOptions);

            if (settingsIndexOld != settingsIndex)
            {
                materialData = new List <TVEMaterialData>();

                if (settingsIndex == 0)
                {
                    materialData.AddRange(motionData);
                    materialData.AddRange(globalData);
                    materialData.AddRange(subsurfaceData);
                    materialData.AddRange(mainData);
                    materialData.AddRange(secondData);
                    materialData.AddRange(gradientAndNoiseData);
                    materialData.AddRange(billboardAndGrassData);
                }
                else if (settingsIndex == 1)
                {
                    materialData = motionData;
                }
                else if (settingsIndex == 2)
                {
                    materialData.AddRange(globalData);
                    materialData.AddRange(subsurfaceData);
                    materialData.AddRange(mainData);
                    materialData.AddRange(secondData);
                    materialData.AddRange(gradientAndNoiseData);
                    materialData.AddRange(billboardAndGrassData);
                }
                else if (settingsIndex == 3)
                {
                    materialData = globalData;
                }
                else if (settingsIndex == 4)
                {
                    materialData = subsurfaceData;
                }
                else if (settingsIndex == 5)
                {
                    materialData = mainData;
                }
                else if (settingsIndex == 6)
                {
                    materialData = secondData;
                }
                else if (settingsIndex == 7)
                {
                    materialData = gradientAndNoiseData;
                }
                else if (settingsIndex == 8)
                {
                    materialData = billboardAndGrassData;
                }

                settingsIndexOld = settingsIndex;
            }

            for (int i = 0; i < materialData.Count; i++)
            {
                if (materialData[i].type == TVEMaterialData.PropertyType.Range)
                {
                    materialData[i].value = StyledSlider(materialData[i].name, materialData[i].value, materialData[i].min, materialData[i].max, materialData[i].snap, materialData[i].space);
                }
                else if (materialData[i].type == TVEMaterialData.PropertyType.Color)
                {
                    materialData[i].color = StyledColor(materialData[i].name, materialData[i].color, materialData[i].hdr, materialData[i].space);
                }
            }

            GUILayout.Space(10);

            SavePreset();

            SetMaterialProperties();

            GUILayout.EndScrollView();

            GUILayout.EndVertical();

            GUILayout.Space(13);
            GUILayout.EndHorizontal();
        }