Exemplo n.º 1
0
        public static UTextureWizard GetWizard(string title, string createButtonName, UTerrainInspector editor)
        {
            UTextureWizard window = EditorWindow.GetWindow <UTextureWizard>(true, title);

            window.createButtonName = createButtonName;
            window.terrain          = editor.terrain;
            window.editor           = editor;
            window.minSize          = new Vector2(300, 500);
            return(window);
        }
Exemplo n.º 2
0
        void PassesField()
        {
            GUILayout.Label("Passes", EditorStyles.boldLabel);
            List <Rect> passRect = new List <Rect>();

            GUILayout.BeginVertical("OL Box");
            GUILayout.Space(4);
            if (subMesh.passes.Length > 0)
            {
                for (int i = 0, max = subMesh.passes.Length; i < max; i++)
                {
                    GUILayout.Box("", EditorStyles.textField, GUILayout.Height(50), GUILayout.MinWidth(235));
                    passRect.Add(GUILayoutUtility.GetLastRect());
                }
            }
            else
            {
                GUILayout.Label("No Pass Added.");
                GUILayout.Space(15);
            }
            GUILayout.Space(2);
            GUILayout.EndVertical();
            for (int i = 0; i < passRect.Count; i++)
            {
                subMesh[i] = PassField(passRect[i], subMesh[i], i);
            }
            GUILayout.Space(2);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            if (GUILayout.Button("Edit Passes...", EditorStyles.popup, GUILayout.Width(90)))
            {
                GenericMenu menu = new GenericMenu();
                if (subMesh.passes.Length > 3)
                {
                    menu.AddDisabledItem(new GUIContent("Add Pass"));
                    m_Editor.Repaint();
                }
                else
                {
                    menu.AddItem(new GUIContent("Add Pass"), false, () => {
                        UTextureWizard wizard = UTextureWizard.GetWizard("Add Pass", "Add", m_Editor);
                        wizard.subMeshIndex   = m_SelectedSM;
                        int width             = 0, height = 0;
                        GetTexSize(ref width, ref height);
                        UPass pass = null;
                        if (subMesh.passes.Length == 0)
                        {
                            pass = new UPass(true, GetClearMix(subMesh.passes.Length));
                        }
                        else
                        {
                            pass = new UPass(false, GetClearMix(subMesh.passes.Length));
                        }
                        wizard.pass = pass;
                    });
                }

                if (subMesh.passes.Length == 0)
                {
                    menu.AddDisabledItem(new GUIContent("Edit Pass"));
                    m_Editor.Repaint();
                }
                else
                {
                    menu.AddItem(new GUIContent("Edit Pass"), false, () => {
                        UTextureWizard wizard = UTextureWizard.GetWizard("Edit Pass", "Apply", m_Editor);
                        wizard.pass           = new UPass(pass);
                        wizard.subMeshIndex   = m_SelectedSM;
                        wizard.passIndex      = m_SelectedPass;
                        m_Editor.Repaint();
                    });
                }
                if (m_SelectedPass == 0)
                {
                    menu.AddDisabledItem(new GUIContent("Remove Pass"));
                }
                else
                {
                    menu.AddItem(new GUIContent("Remove Pass"), false, () => {
                        m_Editor.terrain.data.textureData.subMeshes[m_SelectedSM].RemoveAt(m_SelectedPass);
                        m_SelectedPass = 0;
                        m_Editor.Repaint();
                    });
                }
                menu.ShowAsContext();
                Event.current.Use();
            }
            EditorGUILayout.EndHorizontal();
        }