Пример #1
0
    void PropCreation()
    {
        EditorGUILayout.LabelField("MAKING ROOM INTERIOR!");
        if (Selection.activeGameObject != null && Selection.activeGameObject.activeInHierarchy)
        {
            if (Selection.activeGameObject.GetComponent <ObjectSelector>() == null || Selection.activeGameObject.GetComponent <Door>() == null)
            {
                if (Selection.activeTransform.parent != null)
                {
                    if (Selection.activeTransform.parent.GetComponent <ObjectSelector>() != null || Selection.activeTransform.parent.GetComponent <Door>() != null)
                    {
                        Selection.activeTransform = Selection.activeTransform.parent;
                    }
                }
            }
            if (Selection.activeGameObject.GetComponent <ObjectSelector>() != null)
            {
                EditorGUILayout.LabelField("Currently selected object: ", Selection.activeGameObject.name);
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Duplicate UP"))
                {
                    Duplicate(Selection.activeGameObject, new Vector2(0, 4));
                }
                if (GUILayout.Button("Duplicate DOWN"))
                {
                    Duplicate(Selection.activeGameObject, new Vector2(0, -4));
                }
                if (GUILayout.Button("Duplicate RIGHT"))
                {
                    Duplicate(Selection.activeGameObject, new Vector2(4, 0));
                }
                if (GUILayout.Button("Duplicate LEFT"))
                {
                    Duplicate(Selection.activeGameObject, new Vector2(-4, 0));;
                }
                EditorGUILayout.EndHorizontal();
                if (GUILayout.Button("Delete"))
                {
                    DestroyImmediate(Selection.activeGameObject);
                    return;
                }
            }
            else
            {
                EditorGUILayout.LabelField("No duplicatable object selected");
                GUILayout.Space(42);
            }
            if (GUILayout.Button("Focus"))
            {
                SceneView.lastActiveSceneView.FrameSelected();
            }
            if (Selection.activeGameObject.GetComponent <SmallObjectSelector>() != null || Selection.activeGameObject.GetComponent <MediumObjectSelector>() != null || Selection.activeGameObject.GetComponent <LargeObjectSelector>() != null || Selection.activeGameObject.GetComponent <XLargeObjectSelector>() != null || Selection.activeGameObject.GetComponent <PickupSelector>() != null)
            {
                EditorGUILayout.LabelField("Rotable Object Selected.");
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("+90"))
                {
                    Selection.activeTransform.Rotate(new Vector3(0, 90, 0));
                }
                if (GUILayout.Button("180"))
                {
                    Selection.activeTransform.Rotate(new Vector3(0, 180, 0));
                }
                if (GUILayout.Button("-90"))
                {
                    Selection.activeTransform.Rotate(new Vector3(0, -90, 0));
                }
                EditorGUILayout.EndHorizontal();
            }
            SpawnHazardOrSwitch();
        }
        else
        {
            EditorGUILayout.LabelField("No Object selected");
            GUILayout.Space(64);
        }
        GUILayout.FlexibleSpace();


        GUILayout.FlexibleSpace();
        objectToCreate = EditorGUILayout.Popup("Create new object: ", objectToCreate, new string[] { "Select", "Medium Object", "Large Object", "XLarge Object", "Props", /*"Fuel",*/ "Comic", "Exploding barrel" });
        if (Selection.activeTransform != null)
        {
            tempPos = Selection.activeTransform.position;
        }
        else
        {
            tempPos = Vector3.zero;
        }
        switch (objectToCreate + 3)
        {
        /*case 1:
         *  Selection.activeGameObject = RM.NewHazard(tempPos);
         *  objectToCreate = 0;
         *  break;
         * case 2:
         *  Selection.activeGameObject = RM.NewSwitch(tempPos);
         *  objectToCreate = 0;
         *  break;*/
        /*case 3:
         *  Selection.activeGameObject = RM.NewProp(tempPos, 0);
         *  objectToCreate = 0;
         *  break;*/
        case 4:
            Selection.activeGameObject = RM.NewProp(tempPos, 1);
            objectToCreate             = 0;
            break;

        case 5:
            Selection.activeGameObject = RM.NewProp(tempPos, 2);
            objectToCreate             = 0;
            break;

        case 6:
            Selection.activeGameObject = RM.NewProp(tempPos, 3);
            objectToCreate             = 0;
            break;

        case 7:
            Selection.activeGameObject = RM.NewFloatingProp(tempPos);
            objectToCreate             = 0;
            break;

        /*case 8:
         *  Selection.activeGameObject = RM.NewPickUp(tempPos + new Vector3(0,2,0),0);
         *  objectToCreate = 0;
         *  break;*/
        case 8:
            Selection.activeGameObject = RM.NewPickUp(tempPos + new Vector3(0, 2, 0), 1);
            objectToCreate             = 0;
            break;

        case 9:
            Selection.activeGameObject = RM.NewBarrel(tempPos + new Vector3(0, 1, 0));
            objectToCreate             = 0;
            break;

        default:
            break;
        }

        GUILayout.FlexibleSpace();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Edit room layout", GUILayout.Height(50)))
        {
            states = States.Editing;
        }
        if (GUILayout.Button("Create Decor", GUILayout.Height(50)))
        {
            states = States.Decor;
        }
        GUILayout.EndHorizontal();
    }