Exemplo n.º 1
0
    void DecorCreation()
    {
        EditorGUILayout.LabelField("MAKING ROOM DECOR!");
        if (Selection.activeGameObject != null && Selection.activeGameObject.activeInHierarchy)
        {
            if (Selection.activeGameObject.GetComponent <ObjectSelector>() == null)
            {
                if (Selection.activeTransform.parent != null)
                {
                    if (Selection.activeTransform.parent.GetComponent <ObjectSelector>() != null)
                    {
                        Selection.activeTransform = Selection.activeTransform.parent;
                    }
                }
            }
            if (Selection.activeTransform.parent != null && Selection.activeTransform.parent != RM.GetRoom().decorParent)
            {
                if (Selection.activeTransform.parent.parent != null && Selection.activeTransform.parent.parent == RM.GetRoom().decorParent)
                {
                    Selection.activeTransform = Selection.activeTransform.parent;
                }
            }
            EditorGUILayout.LabelField("Rotable Object Selected.");
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+45"))
            {
                Selection.activeTransform.Rotate(new Vector3(0, 45, 0));
            }
            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));
            }
            if (GUILayout.Button("-45"))
            {
                Selection.activeTransform.Rotate(new Vector3(0, -45, 0));
            }
            EditorGUILayout.EndHorizontal();
        }
        GUILayout.FlexibleSpace();
        List <string> toShow = new List <string>();

        toShow.Add("Select");
        toShow.AddRange(decorItemsNames);
        objectToCreate = EditorGUILayout.Popup("Create new object: ", objectToCreate, toShow.ToArray());

        if (Selection.activeTransform != null)
        {
            tempPos = Selection.activeTransform.position;
        }
        else
        {
            tempPos = Vector3.zero;
        }

        if (objectToCreate != 0)
        {
            Selection.activeGameObject = RM.NewDecorObject(tempPos, decorItems[objectToCreate - 1]);
            objectToCreate             = 0;
        }
        if (GUILayout.Button("Reload Objects (only do this if the dropdown is empty! Or if an object throws an error when you try to create it)"))
        {
            GetDecorNames();
        }

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