void DrawFoliageInstancesEditingUI()
        {
            EditorGUILayout.BeginVertical("Box", GUILayout.Width(450), GUILayout.MaxHeight(200));

            GUILayout.Label("Chunks Settings:", EditorStyles.boldLabel);

            GUILayout.Space(10);

            if (selectedChunk == null)
            {
                GUILayout.Label("Chunk cannot be found!");
            }
            else
            {
                if (!selectedChunk.isFoliageInstanceAttached)
                {
                    GUILayout.Label("Chunk doesn't have a manager attached!");
                }
                else
                {
                    FoliageManagerInstance mInstance = selectedChunk.GetOrCreateFoliageManagerInstance();

                    mInstance.foliageAreaResolution = (FoliageResolutions)EditorGUILayout.EnumPopup("Foliage Area Resolution", mInstance.foliageAreaResolution);

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("World Maps Settings", EditorStyles.boldLabel);

                    GUILayout.FlexibleSpace();

                    if (GUILayout.Button("Generate"))
                    {
                        mInstance.worldMap = UNMapGenerators.GenerateWorldMap(mInstance);
                    }

                    GUILayout.EndHorizontal();

                    mInstance.worldMap.map = (Texture2D)EditorGUILayout.ObjectField(string.Format("World Map: ({0})", mInstance.foliageAreaResolutionIntegral), mInstance.worldMap.map, typeof(Texture2D), false);

                    GUILayout.Space(5);

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Color Maps Settings", EditorStyles.boldLabel);

                    GUILayout.FlexibleSpace();

                    if (GUILayout.Button("Generate"))
                    {
                        mInstance.colorMap = UNMapGenerators.GenerateColorMap(0, 0, FoliageCore_MainManager.FOLIAGE_INSTANCE_AREA_SIZE, mInstance.guid);
                    }

                    GUILayout.EndHorizontal();

                    mInstance.colorMap = (Texture2D)EditorGUILayout.ObjectField(string.Format("Color Map: ({0})", FoliageCore_MainManager.FOLIAGE_INSTANCE_AREA_SIZE), mInstance.colorMap, typeof(Texture2D), false);
                }
            }

            EditorGUILayout.EndVertical();
        }
Beispiel #2
0
        internal static FoliageManagerInstance CreateInstance(FoliageCore_Chunk attachedTo)
        {
            GameObject go = new GameObject("Foliage Manager Instance");

            go.transform.SetParent(attachedTo.transform);

            go.transform.localPosition = Vector3.zero;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;

            FoliageManagerInstance mInstance = go.AddComponent <FoliageManagerInstance>();

            mInstance._attachedTo = attachedTo;

            #if UNITY_EDITOR
            UnityEditor.EditorUtility.DisplayProgressBar("uNature", "Creating Manager Instance - Color Map", 0f);
            #endif

            if (mInstance.colorMap == null)
            {
            }
            ;

            #if UNITY_EDITOR
            UnityEditor.EditorUtility.DisplayProgressBar("uNature", "Creating Manager Instance - Grass Maps", 0.33f);
            #endif

            if (mInstance.grassMaps == null)
            {
            }
            ;

            #if UNITY_EDITOR
            UnityEditor.EditorUtility.DisplayProgressBar("uNature", "Creating Manager Instance - World Map", 0.67f);
            #endif

            if (mInstance.worldMap == null)
            {
            }
            ;

            #if UNITY_EDITOR
            UnityEditor.EditorUtility.ClearProgressBar();
            #endif

            #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                #if UNITY_5_3_OR_NEWER
                UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty();
                #else
                UnityEditor.EditorApplication.MarkSceneDirty();
                #endif
            }
            #endif

            return(mInstance);
        }
Beispiel #3
0
        /// <summary>
        /// Get the attached Foliage Manager Instance and if not availabe, create one.
        /// </summary>
        /// <returns></returns>
        public FoliageManagerInstance GetOrCreateFoliageManagerInstance()
        {
            if (!isFoliageInstanceAttached)
            {
                attachedFoliageInstance = FoliageManagerInstance.CreateInstance(this);
            }

            return(attachedFoliageInstance);
        }