/// <summary> /// Fetch the grass set from the project-based file /// Populate the list of grass configurations /// Sort the grass config list /// Populate the source list /// </summary> private void GetGrassSettings() { if (lbGrassSetup == null) { lbGrassSetup = new LBGrassSetup(); } if (lbGrassSetup != null) { EditorUtility.DisplayProgressBar("Loading grass configurations", "Please Wait", 0f); lbGrassSetup.Retrieve(); if (lbGrassSetup.lbGrassConfigList != null) { int numGrassConfigs = lbGrassSetup.lbGrassConfigList.Count; EditorUtility.ClearProgressBar(); // Get a list of the Texture2D assets for (int i = 0; i < numGrassConfigs; i++) { LBGrassConfig lbGrassConfig = lbGrassSetup.lbGrassConfigList[i]; EditorUtility.DisplayProgressBar("Loading grass settings", "Please Wait", i + 1 / numGrassConfigs); if (lbGrassConfig != null) { lbGrassConfig.texture2D = (Texture2D)AssetDatabase.LoadAssetAtPath(lbGrassConfig.grassTexturePath, typeof(Texture2D)); #if LBGrassEditorAdmin if (lbGrassConfig.texture2D == null) { Debug.Log("LBGrassEditor.GetGrassSettings " + lbGrassConfig.grassTexturePath + " not installed"); } #endif //Debug.Log("GetGrassSettings: " + lbGrassConfig.grassTexturePath); } } // Sort the list by grass texture name lbGrassSetup.lbGrassConfigList.Sort(delegate(LBGrassConfig grass1, LBGrassConfig grass2) { return(grass1.grassTextureName.CompareTo(grass2.grassTextureName)); }); } lbGrassSetup.PopulateSourceList(); EditorUtility.ClearProgressBar(); } }
/// <summary> /// Used to pass in the script to the selector so that it /// can return the LBGrassConfig item selected. /// </summary> /// <param name="lbWindow"></param> public void Initialize(LandscapeBuilderWindow lbWindow, List <LBGrassConfig> lbGrassConfigList) { callingLBWindow = lbWindow; if (lbGrassSetup == null) { lbGrassSetup = new LBGrassSetup(); } if (lbGrassSetup != null) { if (lbGrassSetup.lbGrassConfigList == null) { lbGrassSetup.lbGrassConfigList = new List <LBGrassConfig>(lbGrassConfigList); } if (lbGrassSetup.lbGrassConfigList != null) { isStartedLoading = true; isLoading = true; if (lbGrassSetup.lbGrassConfigList != null) { int grassConfigInt = 0; int numGrassConfigs = lbGrassSetup.lbGrassConfigList.Count; // Get a list of the Texture2D assets // This could be quite memory hungry... foreach (LBGrassConfig lbGrassConfig in lbGrassSetup.lbGrassConfigList) { EditorUtility.DisplayProgressBar("Loading grasses", "Please Wait", (grassConfigInt++) / numGrassConfigs); lbGrassConfig.texture2D = (Texture2D)AssetDatabase.LoadAssetAtPath(lbGrassConfig.grassTexturePath, typeof(Texture2D)); lbGrassConfig.texture2DAlternative = (Texture2D)AssetDatabase.LoadAssetAtPath(lbGrassConfig.grassTextureAlternativePath, typeof(Texture2D)); } // Sort the list by grass texture name lbGrassSetup.lbGrassConfigList.Sort(delegate(LBGrassConfig grass1, LBGrassConfig grass2) { return(grass1.grassTextureName.CompareTo(grass2.grassTextureName)); }); lbGrassSetup.PopulateSourceList(); EditorUtility.ClearProgressBar(); isLoading = false; } } } }