/// <summary>
    /// renders the default Kolmich game framework inspector window (TitleBar, Default Unity Inspector, Infobox, Buttons)
    /// </summary>
    /// <param name="theEditor">
    ///     <see cref="System.String"/>
    /// </param>
    public static void RenderKGFInspector(KGFEditor theEditor, Type theType, Action theHandler)
    {
//		// use fixed skin
//		KGFGUIUtility.SetSkinPath("KGFSkins/default/skins/skin_default_16");

        #region icon loading
        if (itsIconHelp == null)
        {
            itsIconHelp = Resources.Load("KGFCore/textures/help") as Texture2D;
        }

        if (itsIconInfo == null)
        {
            itsIconInfo = Resources.Load("KGFCore/textures/info") as Texture2D;
        }

        if (itsIconWarning == null)
        {
            itsIconWarning = Resources.Load("KGFCore/textures/warning") as Texture2D;
        }

        if (itsIconError == null)
        {
            itsIconError = Resources.Load("KGFCore/textures/error") as Texture2D;
        }

        if (itsIconOK == null)
        {
            itsIconOK = Resources.Load("KGFCore/textures/ok") as Texture2D;
        }
        #endregion

        //set the look to Unity default
        EditorGUIUtility.LookLikeControls();

        KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
        {
            //render the title of the Inspector
            RenderTitle(theEditor.target);

            //render the path and the reference id
            RenderPath(theEditor);

            KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
            {
                KGFGUIUtility.BeginHorizontalPadding();
                {
//					DrawCustomInspector(theEditor);
//					DrawCustomInspectorReflection(theEditor.target,theEditor.target,0);
                    theEditor.DrawDefaultInspector();
                    if (theHandler != null)
                    {
                        theHandler();
                    }
                }
                KGFGUIUtility.EndHorizontalPadding();
            }
            KGFGUIUtility.EndVerticalBox();

            // check if the object is a prefab
            PrefabType aPrefabType = PrefabUtility.GetPrefabType(theEditor.target);
            bool       theIsPrefab = !(aPrefabType == PrefabType.PrefabInstance || aPrefabType == PrefabType.None || aPrefabType == PrefabType.DisconnectedPrefabInstance);

            // draw custom inspector gui
            RenderObjectCustomGui(theEditor.target, theIsPrefab);

            // draw error checking gui
            KGFIValidator aValidator = theEditor.target as KGFIValidator;
            if (aValidator == null)
            {
                KGFMessageList aMessageList = new KGFMessageList();
                aMessageList.AddWarning("Cannot validate: " + theEditor.target.name + " cause it is does not implemet a KGFIValidator");
                RenderInspectorErrorChecking(aMessageList);
            }
            else
            {
                KGFMessageList anEditorMessageList = KGFEditor.ValidateEditor(theEditor.target);
                KGFMessageList aTotalMessageList   = aValidator.Validate();
                aTotalMessageList.AddMessages(anEditorMessageList.GetAllMessagesArray());

                RenderInspectorErrorChecking(aTotalMessageList);
            }

            // help button
            KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkBottom);
            {
                if (KGFGUIUtility.Button(itsIconHelp, "documentation", KGFGUIUtility.eStyleButton.eButton, GUILayout.ExpandWidth(true)))
                {
                    Application.OpenURL("http://www.kolmich.at/documentation/");
                }

                if (KGFGUIUtility.Button(itsIconHelp, "forum", KGFGUIUtility.eStyleButton.eButton, GUILayout.ExpandWidth(true)))
                {
                    Application.OpenURL("http://www.kolmich.at/forum");
                }

                if (KGFGUIUtility.Button(itsIconHelp, "homepage", KGFGUIUtility.eStyleButton.eButton, GUILayout.ExpandWidth(true)))
                {
                    Application.OpenURL("http://www.kolmich.at/");
                }
            }
            KGFGUIUtility.EndHorizontalBox();
        }
        KGFGUIUtility.EndVerticalBox();
    }
Exemple #2
0
    /// <summary>
    /// renders a section for found errors in the inspector
    /// </summary>
    /// <param name="theTarget">the currently displayed data object</param>
    public static void RenderInspectorErrorChecking(UnityEngine.Object theTarget)
    {
        KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical, GUILayout.ExpandWidth(true));
        {
            KGFMessageList aMessageList   = null;
            KGFIValidator  anObjectScript = theTarget as KGFIValidator;

            if (anObjectScript != null)
            {
                aMessageList = anObjectScript.Validate();

                // render infos
                bool aShowOK = true;

                KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxInvisible, GUILayout.ExpandWidth(true));
                {
                    #region render info

                    /*
                     * string[] aInfoList = aMessageList.GetInfoArray();
                     *
                     * if (aInfoList.Length > 0)
                     * {
                     *      aShowOK = false;
                     *
                     *      foreach (string aMessage in aInfoList)
                     *      {
                     *              RenderWarning(aMessage);
                     *      }
                     * }
                     */

                    #endregion

                    #region render errors
                    string[] anErrorList = aMessageList.GetErrorArray();
                    if (anErrorList.Length > 0)
                    {
                        aShowOK = false;

                        foreach (string aMessage in anErrorList)
                        {
                            RenderError(aMessage);
                        }
                    }
                    #endregion

                    #region render warnings
                    anErrorList = aMessageList.GetWarningArray();
                    if (anErrorList.Length > 0)
                    {
                        aShowOK = false;
                        foreach (string aMessage in anErrorList)
                        {
                            RenderWarning(aMessage);
                        }
                    }
                    #endregion

                    if (aShowOK)
                    {
                        RenderOK();
                    }
                }
                KGFGUIUtility.EndVerticalBox();
            }
            else
            {
                RenderError("the module doesn`t implement the KGFIValidator interface");
            }
        }
        KGFGUIUtility.EndVerticalBox();
    }