void InstallAsset() { UpdateShaders(); SettingsUtils.SaveSettingsData(userFolder + "Version.asset", assetVersion); SettingsUtils.SaveSettingsData(userFolder + "Pipeline.asset", "Standard"); SettingsUtils.SaveSettingsData(userFolder + "Engine.asset", engineOptions[coreEngineIndex]); FileUtil.DeleteFileOrDirectory(assetFolder + "/Core/Editor/TVEHubAutorun.cs"); AssetDatabase.Refresh(); SetDefineSymbols("Standard"); SetScriptExecutionOrder(); Debug.Log("[The Vegetation Engine] " + "The Vegetation Engine " + bannerVersion + " is installed!"); GUIUtility.ExitGUI(); }
void OnGUI() { SetGUIStyles(); StyledGUI.DrawWindowBanner(bannerColor, bannerText, helpURL); GUILayout.BeginHorizontal(); GUILayout.Space(15); GUILayout.BeginVertical(); scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false, GUILayout.Width(this.position.width - 28), GUILayout.Height(this.position.height - 80)); if (File.Exists(assetFolder + "/Core/Editor/TVEHubAutoRun.cs")) { if (upgradeIsNeeded) { EditorGUILayout.HelpBox("Previous version detected! The Vegetation Engine will check all project materials and upgrade them if needed. " + "Make sure you read the Upgrading Steps to upgrade to a new version. Do not close Unity during the upgrade!", MessageType.Info, true); GUILayout.Space(10); if (SceneManager.GetActiveScene().name != "") { GUILayout.BeginHorizontal(); GUILayout.Label("Save Current Scene", GUILayout.Width(220)); saveCurrentScene = EditorGUILayout.Toggle(saveCurrentScene); GUILayout.EndHorizontal(); GUILayout.Space(10); } if (GUILayout.Button("Upgrade Materials And Install", GUILayout.Height(24))) { RestartActiveScene(true); UpgradeAsset(); InstallAsset(); } } else { EditorGUILayout.HelpBox("Welcome to the Vegetation Engine! The installer will set up the asset and prepare the shaders for the current Unity version!", MessageType.Info, true); GUILayout.Space(15); if (GUILayout.Button("Install", GUILayout.Height(24))) { InstallAsset(); } } } // TVE is installed else { if (packageIsImported) { EditorGUILayout.HelpBox("The Render Pipeline is not yet installed! Choose and Install the desired Render Engine to finish the setup!", MessageType.Error, true); } else { EditorGUILayout.HelpBox("Click the Render Pipeline Import button then click the Render Engine Update button to use The Vegetation Engine with another render pipeline. Click the Render Engine Install button to update the shader render engine only. The selected features are shared across all TVE shaders. Enable Render Engine Overrides to select per shader Render Engine.", MessageType.Info, true); } GUILayout.Space(15); GUILayout.BeginHorizontal(); GUILayout.Label("Render Pipeline", GUILayout.Width(220)); corePackageIndex = EditorGUILayout.Popup(corePackageIndex, corePackageOptions, stylePopup); if (GUILayout.Button("Import", GUILayout.Width(80), GUILayout.Height(GUI_HEIGHT))) { SettingsUtils.SaveSettingsData(userFolder + "Pipeline.asset", corePackageOptions[corePackageIndex]); SetDefineSymbols(corePackageOptions[corePackageIndex]); ImportPackage(); packageIsImported = true; GUIUtility.ExitGUI(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Render Engine", GUILayout.Width(220)); coreEngineIndex = EditorGUILayout.Popup(coreEngineIndex, engineOptions, stylePopup); if (GUILayout.Button("Install", GUILayout.Width(80), GUILayout.Height(GUI_HEIGHT))) { SettingsUtils.SaveSettingsData(userFolder + "Engine.asset", engineOptions[coreEngineIndex]); UpdateShaders(); if (packageIsImported) { SetMaterialSettings(); } // Refresh overrides if opened showAdvancedSettingsOld = false; packageIsImported = false; GUIUtility.ExitGUI(); } GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("Show Advanced Settings", GUILayout.Width(220)); showAdvancedSettings = EditorGUILayout.Toggle(showAdvancedSettings); GUILayout.EndHorizontal(); if (showAdvancedSettings == true) { if (showAdvancedSettingsOld != showAdvancedSettings) { for (int i = 0; i < coreShaderPaths.Count; i++) { GetRenderEngineFromShader(coreShaderPaths[i], i); } showAdvancedSettingsOld = showAdvancedSettings; } GUILayout.Space(10); for (int i = 0; i < coreShaderPaths.Count; i++) { GUILayout.BeginHorizontal(); GUILayout.Label(Path.GetFileNameWithoutExtension(coreShaderPaths[i]), GUILayout.Width(220)); engineOverridesIndices[i] = EditorGUILayout.Popup(engineOverridesIndices[i], engineOptions, stylePopup); if (GUILayout.Button("Install", GUILayout.Width(80), GUILayout.Height(GUI_HEIGHT))) { InjectShaderFeature(coreShaderPaths[i], engineOptions[engineOverridesIndices[i]]); //AssetDatabase.SaveAssets(); //AssetDatabase.Refresh(); SettingsUtils.SaveSettingsData(userFolder + "Engine.asset", "Mixed Render Engines"); GUIUtility.ExitGUI(); } GUILayout.EndHorizontal(); } } GUILayout.FlexibleSpace(); GUI.enabled = false; GUILayout.Space(20); if (!packageIsImported) { GUILayout.Label("<color=#7f7f7f><size=10><b>Imported Render Pipeline: " + SettingsUtils.LoadSettingsData(userFolder + "Pipeline.asset", "Standard") + "</b></size></color>", styleLabel); GUILayout.Label("<color=#7f7f7f><size=10><b>Installed Render Engine: " + SettingsUtils.LoadSettingsData(userFolder + "Engine.asset", "Unity Default Renderer") + "</b></size></color>", styleLabel); } GUILayout.Space(20); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.Space(13); GUILayout.EndHorizontal(); }
void OnEnable() { //Safer search, there might be many user folders string[] searchFolders; searchFolders = AssetDatabase.FindAssets("The Vegetation Engine"); for (int i = 0; i < searchFolders.Length; i++) { if (AssetDatabase.GUIDToAssetPath(searchFolders[i]).EndsWith("The Vegetation Engine.pdf")) { assetFolder = AssetDatabase.GUIDToAssetPath(searchFolders[i]); assetFolder = assetFolder.Replace("/The Vegetation Engine.pdf", ""); } } searchFolders = AssetDatabase.FindAssets("User"); for (int i = 0; i < searchFolders.Length; i++) { if (AssetDatabase.GUIDToAssetPath(searchFolders[i]).EndsWith("User.pdf")) { userFolder = AssetDatabase.GUIDToAssetPath(searchFolders[i]); userFolder = userFolder.Replace("/User.pdf", ""); userFolder = userFolder + "/The Vegetation Engine/"; } } var cgincGPUI = "Assets/GPUInstancer/Shaders/Include/GPUInstancerInclude.cginc"; searchFolders = AssetDatabase.FindAssets("GPUInstancerInclude"); for (int i = 0; i < searchFolders.Length; i++) { if (AssetDatabase.GUIDToAssetPath(searchFolders[i]).EndsWith("GPUInstancerInclude.cginc")) { cgincGPUI = AssetDatabase.GUIDToAssetPath(searchFolders[i]); } } var cgincNR = "Assets/Visual Design Cafe/Nature Shaders/Common/Nodes/Integrations/Nature Renderer.cginc"; searchFolders = AssetDatabase.FindAssets("Nature Renderer"); for (int i = 0; i < searchFolders.Length; i++) { if (AssetDatabase.GUIDToAssetPath(searchFolders[i]).EndsWith("Nature Renderer.cginc")) { cgincNR = AssetDatabase.GUIDToAssetPath(searchFolders[i]); } } // Add corect paths for VSP and GPUI engineVegetationStudio[1] = engineVegetationStudio[1].Replace("XXX", assetFolder); engineVegetationStudioHD[1] = engineVegetationStudioHD[1].Replace("XXX", assetFolder); engineGPUInstancer[1] = engineGPUInstancer[1].Replace("XXX", cgincGPUI); engineNatureRenderer[1] = engineNatureRenderer[1].Replace("XXX", cgincNR); corePackagesPath = assetFolder + "/Core/Packages"; GetPackages(); GetCoreShaders(); GetAllMaterialGUIDs(); // GetUser Settings if (File.Exists(userFolder + "Asset Version.asset")) { SettingsUtils.SaveSettingsData(userFolder + "Version.asset", SettingsUtils.LoadSettingsData(userFolder + "Asset Version.asset", -99)); FileUtil.DeleteFileOrDirectory(userFolder + "Asset Version.asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (File.Exists(userFolder + "Asset Settings.asset")) { FileUtil.DeleteFileOrDirectory(userFolder + "Asset Settings.asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (File.Exists(userFolder + "Asset Pipeline.asset")) { FileUtil.DeleteFileOrDirectory(userFolder + "Asset Pipeline.asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (File.Exists(userFolder + "Shader Compatibility.asset")) { FileUtil.DeleteFileOrDirectory(userFolder + "Shader Compatibility.asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } assetVersion = SettingsUtils.LoadSettingsData(assetFolder + "/Core/Editor/TVEVersion.asset", -99); userVersion = SettingsUtils.LoadSettingsData(userFolder + "Version.asset", -99); unityMajorVersion = int.Parse(Application.unityVersion.Substring(0, 4)); if (userVersion == -99) { // Looks like new install, but User folder might be deleted so check for TVE materials for (int i = 0; i < allMaterialGUIDs.Length; i++) { var path = AssetDatabase.GUIDToAssetPath(allMaterialGUIDs[i]); // Exclude TVE folder when checking if (path.Contains("TVE Material") && path.Contains("The Vegetation Engine") == false) { upgradeIsNeeded = true; break; } } } // User Version exist and need upgrade if (userVersion != -99 && userVersion < assetVersion) { upgradeIsNeeded = true; } // Curent version was installed but deleted and reimported if (userVersion == assetVersion) { upgradeIsNeeded = false; } for (int i = 0; i < corePackageOptions.Length; i++) { if (corePackageOptions[i] == SettingsUtils.LoadSettingsData(userFolder + "Pipeline.asset", "")) { corePackageIndex = i; } } for (int i = 0; i < engineOptions.Length; i++) { if (engineOptions[i] == SettingsUtils.LoadSettingsData(userFolder + "Engine.asset", "")) { coreEngineIndex = i; } } bannerVersion = assetVersion.ToString(); bannerVersion = bannerVersion.Insert(1, "."); bannerVersion = bannerVersion.Insert(3, "."); bannerColor = new Color(0.890f, 0.745f, 0.309f); bannerText = "The Vegetation Engine " + bannerVersion; helpURL = "https://docs.google.com/document/d/145JOVlJ1tE-WODW45YoJ6Ixg23mFc56EnB_8Tbwloz8/edit#heading=h.pr0qp2u684tr"; // Check for latest version //StartBackgroundTask(StartRequest("https://boxophobic.com/s/thevegetationengine", () => //{ // int.TryParse(www.downloadHandler.text, out latestVersion); // Debug.Log("hubhub" + latestVersion); //})); }