示例#1
0
        static void Init()
        {
            LMGEditorWindow myWindow = (LMGEditorWindow)EditorWindow.GetWindow(typeof(LMGEditorWindow));

            myWindow.titleContent = new GUIContent("Generator Editor");
            myWindow.Show();
        }
示例#2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
//			if (myWindow == null)
//				myWindow = (LMGEditorWindow)EditorWindow.GetWindow (typeof(LMGEditorWindow));
            color  = property.FindPropertyRelative("color");
            prefab = property.FindPropertyRelative("prefab");
            int oldIndentLevel = EditorGUI.indentLevel;

            label = EditorGUI.BeginProperty(position, label, property);
            Rect contentPosition = EditorGUI.PrefixLabel(position, label);

            if (position.height > 16f)
            {
                position.height        = 16f;
                EditorGUI.indentLevel += 1;
                contentPosition        = EditorGUI.IndentedRect(position);
                contentPosition.y     += 18f;
            }
            contentPosition.width *= 0.55f;
            EditorGUI.indentLevel  = 0;
            EditorGUI.PropertyField(contentPosition, prefab, GUIContent.none);
            contentPosition.x          += contentPosition.width;
            contentPosition.width      /= 2f;
            EditorGUIUtility.labelWidth = 14f;
            EditorGUI.BeginChangeCheck();
            EditorGUI.PropertyField(contentPosition, color, new GUIContent("C"));
            if (EditorGUI.EndChangeCheck() && myWindow != null)
            {
                if (prefab.objectReferenceValue != null)
                {
                    myWindow.SetColor(color.colorValue, (prefab.objectReferenceValue as GameObject).name);
                }
                else
                {
                    Debug.LogWarning("No prefab has been asigned, check you references");
                }
            }
            contentPosition.x     += contentPosition.width;
            contentPosition.width /= 2f;
            if (GUI.Button(contentPosition, "+", EditorStyles.miniButton))
            {
                // set color left button editor window
                if (myWindow == null)
                {
                    myWindow = (LMGEditorWindow)EditorWindow.GetWindow(typeof(LMGEditorWindow));
                }
                if (prefab.objectReferenceValue != null)
                {
                    myWindow.SetColor(color.colorValue, (prefab.objectReferenceValue as GameObject).name);
                }
                else
                {
                    Debug.LogWarning("No prefab has been asigned, check you references");
                }
            }
            EditorGUI.EndProperty();
            EditorGUI.indentLevel = oldIndentLevel;
        }
        public void OnWindowGUI()
        {
            var trg = (LevelPlatformerGenerator)target;

            EditorGUI.BeginChangeCheck();

            DrawDefaultInspector();

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            if (GUILayout.Button(generate, EditorStyles.miniButtonLeft, miniButtonWidth))
            {
                trg.GenerateLevel();
            }
            if (GUILayout.Button(generateColliders, EditorStyles.miniButtonMid, miniButtonWidth))
            {
                trg.CheckMaterials();
            }
            if (GUILayout.Button(setColliders, EditorStyles.miniButtonMid, miniButtonWidth))
            {
                trg.AttachColliders();
            }
            if (GUILayout.Button(createPrefab, EditorStyles.miniButtonMid, miniButtonWidth))
            {
                trg.CreatePrefab();
            }
            if (GUILayout.Button(clear, EditorStyles.miniButtonRight, miniButtonWidth))
            {
                trg.Clean();
            }
            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                if (win == null)
                {
                    win = (LMGEditorWindow)EditorWindow.GetWindow(typeof(LMGEditorWindow));
                }
                setUp = (LevelGeneratorSetUp)serializedObject.FindProperty("setUp").objectReferenceValue;
                if (setUp != null)
                {
                    win.SetTexture((Texture2D)setUp.editorGeneratorLevel);
                }
            }

            EditorUtility.SetDirty(trg);
        }
        public override void OnInspectorGUI()
        {
            var trg = (LevelPlatformerGenerator)target;

            if (GUILayout.Button("Edit"))
            {
                if (win == null)
                {
                    win = (LMGEditorWindow)EditorWindow.GetWindow(typeof(LMGEditorWindow));
                }
                win.SetType(GENERATOR_TO_EDIT.Level, trg);
                win.OpenWindow();
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            if (serializedObject == null)
            {
                return;
            }

            Init();

            var trg = (LevelGeneratorSetUp)target;

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(new GUIContent("Level/Map to Generate"), EditorStyles.boldLabel);
            EditorGUILayout.Space();

            EditorGUI.indentLevel++;

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(level, new GUIContent("Level/Map Texture"));
            if (EditorGUI.EndChangeCheck())
            {
                if (myWindow == null)
                {
                    myWindow = (LMGEditorWindow)EditorWindow.GetWindow(typeof(LMGEditorWindow));
                }
                myWindow.SetTexture((Texture2D)level.objectReferenceValue);
            }

            EditorGUI.indentLevel--;

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(new GUIContent("Block Size", "Unity units (1/100 pixel)"), EditorStyles.boldLabel);
            EditorGUILayout.Space();

            EditorGUI.indentLevel++;

            EditorGUILayout.PropertyField(size, new GUIContent("Size", "Size to represent one pixel"));

            EditorGUI.indentLevel--;

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(new GUIContent("Entities and Blocks to Generate"), EditorStyles.boldLabel);
            EditorGUILayout.Space();

            EditorGUI.indentLevel++;

            EditorGUILayout.PropertyField(entities, new GUIContent("Entities", "Entities in Level/Map"), true);

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(objects, new GUIContent("Objects", "Objects to make Level/Map (Not Wall or Floor)"), true);

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(singleWF, new GUIContent("Single Wall/Floor", "Mark if you only need one block for the wall and the floor"));

            using (var group = new EditorGUILayout.FadeGroupScope(Convert.ToSingle(trg.singleWallFloor))) {
                if (group.visible)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(new GUIContent("Single Wall and Floor blocks"), EditorStyles.boldLabel);
                    EditorGUILayout.Space();

                    EditorGUI.indentLevel++;

                    EditorGUILayout.PropertyField(wall, new GUIContent("Single Wall", "Only one block for the wall"));
                    EditorGUILayout.PropertyField(floor, new GUIContent("Single Floor", "Only one block for the floor"));

                    EditorGUI.indentLevel--;
                }
                else
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(new GUIContent("Multiple Wall and Floor blocks"), EditorStyles.boldLabel);
                    EditorGUILayout.Space();

                    EditorGUI.indentLevel++;

                    EditorGUILayout.PropertyField(wallObjects, new GUIContent("Multiple Wall Objects", "Multiple blocks for the wall"), true);
                    EditorGUILayout.PropertyField(floorObjects, new GUIContent("Multiple Floor Objects", "Multiple blocks for the floor"), true);

                    EditorGUI.indentLevel--;
                }
            }

            EditorGUI.indentLevel--;

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(new GUIContent("Color for the air", "Default color white"), EditorStyles.boldLabel);
            EditorGUILayout.Space();

            EditorGUI.indentLevel++;

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(airColor, new GUIContent("Air Color", "Color representing air"));
            if (EditorGUI.EndChangeCheck() && myWindow != null)
            {
                if (myWindow == null)
                {
                    myWindow = (LMGEditorWindow)EditorWindow.GetWindow(typeof(LMGEditorWindow));
                }
                myWindow.SetColor(airColor.colorValue, "Air");
            }
            if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.MaxWidth(40)))
            {
                if (myWindow == null)
                {
                    myWindow = (LMGEditorWindow)EditorWindow.GetWindow(typeof(LMGEditorWindow));
                }
                myWindow.SetColor(airColor.colorValue, "Air");
            }
            EditorGUILayout.EndHorizontal();

            EditorGUI.indentLevel--;

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(new GUIContent("More Options", "Check if need"), EditorStyles.boldLabel);
            EditorGUILayout.Space();

            EditorGUI.indentLevel++;

            EditorGUILayout.PropertyField(exOp, new GUIContent("Extra Options", "Extra objects to place"));


            using (var group = new EditorGUILayout.FadeGroupScope(Convert.ToSingle(trg.extraOptions))) {
                if (group.visible)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(deathZone, new GUIContent("Death Area", "For platformer, under level death"));
                    EditorGUILayout.PropertyField(player, new GUIContent("Player", "If player is needed to be place"));
                    EditorGUILayout.PropertyField(dim2, new GUIContent("2D Mode", "Is your game in 2D"));
                    EditorGUILayout.Space();

                    EditorGUI.indentLevel--;

                    EditorGUILayout.LabelField(new GUIContent("Physical Material", "Physical Material added to all colliders (specified color if not single material)"), EditorStyles.boldLabel);

                    EditorGUI.indentLevel++;

                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(singleMat, new GUIContent("Single Material", "Are you using only one material?"));

                    using (var group2 = new EditorGUILayout.FadeGroupScope(Convert.ToSingle(trg.singleMat))) {
                        if (group2.visible)
                        {
                            using (var group3 = new EditorGUILayout.FadeGroupScope(Convert.ToSingle(trg.dim2))) {
                                if (group3.visible)
                                {
                                    EditorGUILayout.PropertyField(singleMaterial2D, new GUIContent("Physical Material 2D", "Physics Material for every collider (2D only)"));
                                }
                                else
                                {
                                    EditorGUILayout.PropertyField(singleMaterial, new GUIContent("Physical Material", "Physics Material for every collider (3D only)"));
                                }
                            }
                        }
                        else
                        {
                            using (var group4 = new EditorGUILayout.FadeGroupScope(Convert.ToSingle(trg.dim2))) {
                                if (group4.visible)
                                {
                                    EditorGUILayout.PropertyField(material2D, new GUIContent("Physical Material 2D", "Physics Material for color collider (2D only)"), true);
                                }
                                else
                                {
                                    EditorGUILayout.PropertyField(material, new GUIContent("Physical Material", "Physics Material for color collider (3D only)"), true);
                                }
                            }
                        }
                    }
                }
            }

            EditorGUI.indentLevel--;

            EditorGUILayout.Space();
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            EditorUtility.SetDirty(trg);
        }
示例#6
0
        public override void OnInspectorGUI()
        {
//			if (myWindow == null)
//				myWindow = (LMGEditorWindow)EditorWindow.GetWindow (typeof(LMGEditorWindow));
            serializedObject.Update();
            if (serializedObject == null)
            {
                return;
            }
            Init();

            var trg = (MapGeneratorSetUp)target;

            if (trg == null)
            {
                return;
            }

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(new GUIContent("Level/Map to Generate"), EditorStyles.boldLabel);
            EditorGUILayout.Space();

            EditorGUI.indentLevel++;

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(level, new GUIContent("Level/Map Texture"));
            if (EditorGUI.EndChangeCheck())
            {
                if (myWindow == null)
                {
                    myWindow = (LMGEditorWindow)EditorWindow.GetWindow(typeof(LMGEditorWindow));
                }
                myWindow.SetTexture((Texture2D)level.objectReferenceValue);
            }

            EditorGUI.indentLevel--;

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(new GUIContent("Block Size", "Unity units (1/100 pixel)"), EditorStyles.boldLabel);
            EditorGUILayout.Space();

            EditorGUI.indentLevel++;

            EditorGUILayout.PropertyField(size, new GUIContent("Size", "Size to represent one pixel"));

            EditorGUI.indentLevel--;

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(new GUIContent("Entities and Blocks to Generate"), EditorStyles.boldLabel);
            EditorGUILayout.Space();

            EditorGUI.indentLevel++;

            EditorGUILayout.PropertyField(entities, new GUIContent("Entities", "Entities in Level/Map"), true);

            EditorGUILayout.PropertyField(objects, new GUIContent("Objects", "Objects to make Level/Map"), true);

            EditorGUILayout.PropertyField(misc, new GUIContent("Misc Objects", "Decoration for the Level/Map"), true);
            if (misc.arraySize > 0)
            {
                EditorGUI.indentLevel++;

                rotCollapse = EditorGUILayout.Foldout(rotCollapse, new GUIContent("Random Rotation", "Random values between 2 vectors."), true);

                if (rotCollapse)
                {
                    EditorGUI.indentLevel++;

                    EditorGUILayout.PropertyField(minRotation, new GUIContent("Minimun", "Minimun rotation factor"));

                    EditorGUILayout.PropertyField(maxRotation, new GUIContent("Maximun", "Maximun rotation factor"));

                    EditorGUILayout.Space();
                    EditorGUI.indentLevel--;
                }

                scaleCollapse = EditorGUILayout.Foldout(scaleCollapse, new GUIContent("Random Scale", "Random values between 2 vectors."), true);

                if (scaleCollapse)
                {
                    EditorGUI.indentLevel++;

                    EditorGUILayout.PropertyField(minScale, new GUIContent("Minimun", "Minimun scale factor"));

                    EditorGUILayout.PropertyField(maxScale, new GUIContent("Maximun", "Maximun scale factor"));

                    EditorGUILayout.Space();
                    EditorGUI.indentLevel--;
                }
            }
            EditorGUI.indentLevel--;

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(new GUIContent("More Options", "Check if need"), EditorStyles.boldLabel);
            EditorGUILayout.Space();

            EditorGUI.indentLevel++;

            EditorGUILayout.PropertyField(exOp, new GUIContent("Extra Options", "Extra objects to place"));
            if (!exOp.boolValue)
            {
                horizontal.boolValue = false;
            }
            using (var group = new EditorGUILayout.FadeGroupScope(Convert.ToSingle(trg.extraOptions))) {
                if (group.visible)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(player, new GUIContent("Player", "If player is needed to be place"));
                    EditorGUILayout.PropertyField(horizontal, new GUIContent("Horizontal", "Is your game horizontaly placed"));
                    EditorGUI.indentLevel--;
//					using (var group2 = new EditorGUILayout.FadeGroupScope (Convert.ToSingle (trg.horizontal))) {
//						if (group2.visible) {
                    objCollapse = EditorGUILayout.Foldout(objCollapse, new GUIContent("Path Objects", "Prefabs for creating a path."), true);
                    if (objCollapse)
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.PropertyField(straight, new GUIContent("Straight Path", "Straight path prefab"));
                        EditorGUILayout.PropertyField(curve, new GUIContent("Corner Path", "Corner path prefab"));
                        EditorGUILayout.PropertyField(cross, new GUIContent("Cross Section Path", "Cross Section path prefab"));
                        EditorGUILayout.PropertyField(begin, new GUIContent("Begining Path", "Begining path prefab"));
                        EditorGUILayout.PropertyField(end, new GUIContent("Ending Path", "Ending path prefab"));
                        EditorGUILayout.Space();
                        EditorGUI.indentLevel--;
                    }
                    colorCollapse = EditorGUILayout.Foldout(colorCollapse, new GUIContent("Path Colors", "Color for placing the path."), true);
                    if (colorCollapse)
                    {
                        EditorGUI.indentLevel++;

                        EditorGUILayout.BeginHorizontal();
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.PropertyField(pathColor, new GUIContent("Path Color", "Straight and corner path color"));
                        if (EditorGUI.EndChangeCheck() && myWindow != null)
                        {
                            myWindow.SetColor(pathColor.colorValue, "Path");
                        }
                        if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.MaxWidth(40)))
                        {
                            if (myWindow == null)
                            {
                                myWindow = (LMGEditorWindow)EditorWindow.GetWindow(typeof(LMGEditorWindow));
                            }
                            if (straight.objectReferenceValue != null && curve.objectReferenceValue != null)
                            {
                                myWindow.SetColor(pathColor.colorValue, "Path");
                            }
                            else
                            {
                                Debug.LogWarning("No prefab for straight path or corner has been asigned, check you references");
                            }
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal();
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.PropertyField(beginColor, new GUIContent("Begining Color", "Begining path color"));
                        if (EditorGUI.EndChangeCheck() && myWindow != null)
                        {
                            myWindow.SetColor(beginColor.colorValue, "Begining");
                        }
                        if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.MaxWidth(40)))
                        {
                            if (myWindow == null)
                            {
                                myWindow = (LMGEditorWindow)EditorWindow.GetWindow(typeof(LMGEditorWindow));
                            }
                            if (begin.objectReferenceValue != null)
                            {
                                myWindow.SetColor(beginColor.colorValue, "Begining");
                            }
                            else
                            {
                                Debug.LogWarning("No prefab for begining has been asigned, check you references");
                            }
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal();
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.PropertyField(endColor, new GUIContent("Ending Color", "Ending path color"));
                        if (EditorGUI.EndChangeCheck() && myWindow != null)
                        {
                            myWindow.SetColor(endColor.colorValue, "Ending");
                        }
                        if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.MaxWidth(40)))
                        {
                            if (myWindow == null)
                            {
                                myWindow = (LMGEditorWindow)EditorWindow.GetWindow(typeof(LMGEditorWindow));
                            }
                            if (end.objectReferenceValue != null)
                            {
                                myWindow.SetColor(endColor.colorValue, "Ending");
                            }
                            else
                            {
                                Debug.LogWarning("No prefab for ending has been asigned, check you references");
                            }
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.Space();
                        EditorGUI.indentLevel--;
                    }
//						}
//					}
                }
            }
            //
            //		EditorGUILayout.Space ();
            //
            //		EditorGUILayout.BeginHorizontal();
            //
            //		GUILayout.FlexibleSpace ();
            //
            //		if(GUILayout.Button (generate, EditorStyles.miniButtonLeft, miniButtonWidth)){
            //
            //			trg.GenerateLevel ();
            //
            //		}
            //
            //		if(GUILayout.Button (createPrefab, EditorStyles.miniButtonMid, miniButtonWidth)){
            //
            //			trg.CreatePrefab ();
            //
            //		}
            //
            //		if(GUILayout.Button (clear, EditorStyles.miniButtonRight, miniButtonWidth)){
            //
            //			trg.Clean();
            //
            //		}
            //		GUILayout.FlexibleSpace ();
            //
            //		EditorGUILayout.EndHorizontal ();

            EditorGUILayout.Space();
            EditorGUI.indentLevel = 0;
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
            EditorUtility.SetDirty(trg);
        }