Exemplo n.º 1
0
    void OnGUI()
    {
        // Is all in order with the Archimatix install?
        if (string.IsNullOrEmpty(ArchimatixEngine.pathChangelog) || string.IsNullOrEmpty(changelogText))
        {
            return;
        }

        if (richLabelStyle == null)
        {
            richLabelStyle           = new GUIStyle(GUI.skin.label);
            richLabelStyle.richText  = true;
            richLabelStyle.wordWrap  = true;
            richButtonStyle          = new GUIStyle(GUI.skin.button);
            richButtonStyle.richText = true;

            textLabelStyle            = new GUIStyle(GUI.skin.label);
            textLabelStyle.richText   = true;
            textLabelStyle.wordWrap   = true;
            textLabelStyle.alignment  = TextAnchor.MiddleLeft;
            textLabelStyle.fixedWidth = 510;

            iconButtonStyle = new GUIStyle(GUI.skin.button);
            iconButtonStyle.normal.background = null;
            iconButtonStyle.imagePosition     = ImagePosition.ImageOnly;
            iconButtonStyle.fixedWidth        = 128;
            iconButtonStyle.fixedHeight       = 128;
        }

        Rect headerRect = new Rect(0, 0, 530, 200);

        EditorGUI.DrawTextureTransparent(headerRect, headerPic, ScaleMode.StretchToFill);


        GUILayout.Space(200);

        GUILayout.BeginVertical();
        {
            // What to do next....
            horizontalRule(0, 2);

            /*
             * GUILayout.BeginHorizontal();
             * GUILayout.FlexibleSpace();
             * GUILayout.Label ("Version " +ArchimatixEngine.version, richLabelStyle);
             * GUILayout.FlexibleSpace();
             * GUILayout.EndHorizontal();
             */


            // TOP BUTTONS

            GUILayout.BeginHorizontal();

            GUILayout.Space(5);


            // User GUIDE
            if (GUILayout.Button("<b>User Guide </b>\n<size=12>The best way to get started</size>", richButtonStyle, GUILayout.MaxWidth(400), GUILayout.Height(36)))
            {
                string file = "file:///" + Application.dataPath + "/Archimatix/Documentation/UserGuide.pdf";
                Application.OpenURL(file);
            }



            // TUTORIALS
            if (GUILayout.Button("<b>Tutorial Videos </b>\n<size=12>Watch a range of how-tos</size>", richButtonStyle, GUILayout.MaxWidth(400), GUILayout.Height(36)))
            {
                Application.OpenURL("http://www.archimatix.com/tutorials");
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.Space(4);

            GUILayout.Label("Or, click on one of these to jump right in!", textLabelStyle, new GUILayoutOption[] { GUILayout.MinWidth(450) });

            GUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button(icon3DLibrary, iconButtonStyle))
                {
                    ArchimatixEngine.openLibrary3D();
                }


                if (GUILayout.Button(icon2DLibrary, iconButtonStyle))
                {
                    ArchimatixEngine.openLibrary2D();
                }


                //if (ArchimatixEngine.NodeGraphEditorIsInstalled)
                //{

                if (GUILayout.Button(iconAXEditor, iconButtonStyle))
                {
                    AXNodeGraphEditorWindow.Init();
                }


                //}


                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();
        }



        horizontalRule(4, 1);



        // CHANGE_LOG

        GUILayout.BeginHorizontal();
        changelogScroll = GUILayout.BeginScrollView(changelogScroll, GUIStyle.none, new GUIStyle(GUI.skin.verticalScrollbar));
        GUILayout.Label(changelogText, textLabelStyle);
        GUILayout.EndScrollView();
        GUILayout.EndHorizontal();



        horizontalRule(0, 4);


        GUILayout.BeginHorizontal();
        {
            showAcknowledgements = EditorGUILayout.Foldout(showAcknowledgements, "Acknowledgments", true);

            if (showAcknowledgements)
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.TextArea("Special thanks to Unity community members in the Beta Team: @elbows, @S_Darkwell, @HeliosDoubleSix, @Teila, @wetcircuit, @radimoto @puzzlekings, @mangax, @sarum, @Sheriziya, @Voronoi, @steveR, @manpower13, @vrpostcard, @Whippets, @pixelstream, @Damien-Delmarle, @recursive, @sloopidoopi, @KWaldt, @pcg, @Hitch42, @Bitstream, @CognitiveCode, @ddutchie, @JacooGamer, @razmot, @angrypenguin, @Paylo, @AdamGoodrich. Also, for much needed feedback and support, many thanks to Eden Muir, Andrew Cortese, Lucas Meijer, Sanjay Mistry, Dominic Laflamme, Rune Skovbo, Alan Robles, Luke Noonan, Anton Hand, Lucas Miller, and Joachim Holmér");
                }
                GUILayout.EndHorizontal();
            }
        }
        GUILayout.EndHorizontal();
        // BOTTOM BUTTON - DOCUMENTATION

        GUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("<b>Documentation</b>\n<size=12>Manual, examples and tips</size>", richButtonStyle, GUILayout.MaxWidth(260), GUILayout.Height(36)))
            {
                Application.OpenURL("http://archimatix.com/documentation");
            }

            if (GUILayout.Button("<b>Rate it</b>\n<size=12>on the Asset Store</size>", richButtonStyle, GUILayout.Height(36)))
            {
                Application.OpenURL("http://u3d.as/qYW");
                //Application.OpenURL("com.unity3d.kharma:content/?");
            }
            if (GUILayout.Button("<b>Join the Community!</b>\n<size=12>We're are building worlds.</size>", richButtonStyle, GUILayout.Height(36)))
            {
                Application.OpenURL("http://community.archimatix.com");
                //Application.OpenURL("com.unity3d.kharma:content/?");
            }
        }
        GUILayout.EndHorizontal();



        // Contact
        horizontalRule(4, 2);

        GUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("<b>E-mail</b>\n<size=12>[email protected]</size>", richButtonStyle, GUILayout.MaxWidth(172), GUILayout.Height(36)))
            {
                Application.OpenURL("mailto:[email protected]");
            }

            if (GUILayout.Button("<b>Twitter</b>\n<size=12>@archimatix</size>", richButtonStyle, GUILayout.Height(36)))
            {
                Application.OpenURL("http://twitter.com/archimatix");
            }

            // UNITY FORUM
            if (GUILayout.Button("<b>Unity Forum</b>\n<size=12>The Original!</size>", richButtonStyle, GUILayout.MaxWidth(172), GUILayout.Height(36)))
            {
                Application.OpenURL("http://bit.ly/2gj4oax");
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        GUILayout.EndVertical();
    }
        // return the height of this gui area
        public static void OnGUI(Rect headerRect, AXNodeGraphEditorWindow editor)
        {
            Event e = Event.current;

            AXModel model = editor.model;

            // DO HEADER MENU BAR -- MODEL MENU


            GUILayout.BeginArea(headerRect);
            GUILayout.BeginHorizontal();

            GUIStyle labelstyle = new GUIStyle(GUI.skin.label);

            labelstyle.alignment = TextAnchor.LowerLeft;

            labelstyle.fixedWidth = 150;


            GUILayout.Space(5);


            if (GUILayout.Button("2D"))
            {
                ArchimatixEngine.openLibrary2D();
            }
            if (GUILayout.Button("3D"))
            {
                ArchimatixEngine.openLibrary3D();
            }



            // NEW MODEL
            GUILayout.Space(10);



            if (GUILayout.Button("▼"))
            {
                AXModel[] allModels = ArchimatixUtils.getAllModels();


                GenericMenu menu = new GenericMenu();

                //menu.AddSeparator("Library ...");


                if (allModels != null && allModels.Length > 0)
                {
                    for (int i = 0; i < allModels.Length; i++)
                    {
                        AXModel m = allModels [i];
                        menu.AddItem(new GUIContent(m.gameObject.name), false, () => {
                            Selection.activeGameObject    = m.gameObject;
                            ArchimatixEngine.currentModel = m;
                        });
                    }
                }


                menu.AddSeparator("");

                menu.AddItem(new GUIContent("New Model"), false, () => {
                    AXEditorUtilities.createNewModel();
                });

                menu.ShowAsContext();
            }



            Color bgc = GUI.backgroundColor;

            GUI.backgroundColor = Color.clear;



            if (model != null)
            {
                // SELECTED MODEL
                if (GUILayout.Button(model.name))
                {
                    model.currentWorkingGroupPO = null;

                    model.selectAllVisibleInGroup(null);

                    float framePadding = 50;

                    Rect allRect = AXUtilities.getBoundaryRectFromPOs(model.selectedPOs);
                    allRect.x      -= framePadding;
                    allRect.y      -= framePadding;
                    allRect.width  += framePadding * 2;
                    allRect.height += framePadding * 2;



                    AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect);
                }



                if (model.currentWorkingGroupPO != null)
                {
                    if (model.currentWorkingGroupPO.grouper != null)
                    {
                        // Make breadcrumb trail
                        List <AXParametricObject> crumbs = new List <AXParametricObject>();
                        AXParametricObject        cursor = model.currentWorkingGroupPO;


                        while (cursor.grouper != null)
                        {
                            crumbs.Add(cursor.grouper);
                            cursor = cursor.grouper;
                        }
                        crumbs.Reverse();

                        // model button frames



                        for (int i = 0; i < crumbs.Count; i++)
                        {
                            if (GUILayout.Button("> " + crumbs[i].Name))
                            {
                                model.currentWorkingGroupPO = crumbs[i];
                                Rect grouperCanvasRect = model.currentWorkingGroupPO.getBoundsRect();
                                editor.zoomToRect(grouperCanvasRect);
                            }
                        }
                    }
                    GUILayout.Button("> " + model.currentWorkingGroupPO.Name);
                }
            }
            GUILayout.FlexibleSpace();



            if (model != null)
            {
                Color  buildBG    = Color.Lerp(Color.cyan, Color.white, .8f);
                string buildLabel = "Rebuild";



                if (model.buildStatus == AXModel.BuildStatus.Generated)
                {
                    buildBG    = Color.red;
                    buildLabel = "Build";
                }



                GUI.backgroundColor = buildBG;
                if (GUILayout.Button(buildLabel))
                {
                    model.build();
                }

                GUI.backgroundColor = Color.cyan;


                if (model.generatedGameObjects != null && model.generatedGameObjects.transform.childCount == 0)
                {
                    GUI.enabled = false;
                }

                if (GUILayout.Button("Stamp"))
                {
                    model.stamp();
                }

                if (GUILayout.Button("Prefab"))
                {
                    string startDir = Application.dataPath;

                    string path = EditorUtility.SaveFilePanel(
                        "Save Prefab",
                        startDir,
                        ("" + model.name),
                        "prefab");

                    if (!string.IsNullOrEmpty(path))
                    {
                        AXPrefabWindow.makePrefab(model, path, editor);
                    }
                }
                GUI.enabled = true;

                GUILayout.Space(4);
            }


            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            GUI.backgroundColor = bgc;
        }