void OnGUI() { int aWidth = 300; int aHeight = 250; Rect aRect = new Rect((Screen.width - aWidth) / 2, (Screen.height - aHeight) / 2, aWidth, aHeight); GUILayout.BeginArea(aRect); { KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxInvisible, GUILayout.ExpandHeight(true)); { KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop); { GUILayout.FlexibleSpace(); KGFGUIUtility.Label("KGFGUIUtility Tutorial", KGFGUIUtility.eStyleLabel.eLabel); GUILayout.FlexibleSpace(); } KGFGUIUtility.EndHorizontalBox(); KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical, GUILayout.ExpandHeight(true)); { GUILayout.FlexibleSpace(); KGFGUIUtility.BeginHorizontalPadding(); { KGFGUIUtility.Button("Top", KGFGUIUtility.eStyleButton.eButtonTop, GUILayout.ExpandWidth(true)); KGFGUIUtility.Button("Middle", KGFGUIUtility.eStyleButton.eButtonMiddle, GUILayout.ExpandWidth(true)); KGFGUIUtility.Button("Bottom", KGFGUIUtility.eStyleButton.eButtonBottom, GUILayout.ExpandWidth(true)); } KGFGUIUtility.EndHorizontalPadding(); GUILayout.FlexibleSpace(); } KGFGUIUtility.EndVerticalBox(); KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkBottom); { KGFGUIUtility.BeginVerticalPadding(); { KGFGUIUtility.Button("Left", KGFGUIUtility.eStyleButton.eButtonLeft, GUILayout.ExpandWidth(true)); KGFGUIUtility.Button("Center", KGFGUIUtility.eStyleButton.eButtonMiddle, GUILayout.ExpandWidth(true)); KGFGUIUtility.Button("Right", KGFGUIUtility.eStyleButton.eButtonRight, GUILayout.ExpandWidth(true)); } KGFGUIUtility.EndVerticalPadding(); } KGFGUIUtility.EndHorizontalBox(); } KGFGUIUtility.EndVerticalBox(); } GUILayout.EndArea(); }
/// <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(); }
private static void RenderHelpWindowMethod(int theWindowID) { GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxInvisible, GUILayout.ExpandHeight(true)); { KGFGUIUtility.BeginHorizontalPadding(); { KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop, GUILayout.ExpandWidth(true)); { GUILayout.FlexibleSpace(); GUILayout.Label(KGFGUIUtility.GetLogo(), GUILayout.Height(50)); GUILayout.FlexibleSpace(); } KGFGUIUtility.EndHorizontalBox(); KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxBottom, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); { GUILayout.Label(itsCopyrightText, GUILayout.ExpandWidth(true)); } KGFGUIUtility.EndHorizontalBox(); GUILayout.Space(KGFGUIUtility.GetSkinHeight()); KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop, GUILayout.ExpandWidth(true)); { KGFGUIUtility.Label(itsOpenModule.GetName() + " version:", KGFGUIUtility.eStyleLabel.eLabelFitIntoBox); KGFGUIUtility.Label(itsOpenModule.GetCurrentVersion().ToString(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox); GUILayout.FlexibleSpace(); KGFGUIUtility.Label("req. KGFCore version:", KGFGUIUtility.eStyleLabel.eLabelFitIntoBox); KGFGUIUtility.Label(itsOpenModule.GetRequiredCoreVersion().ToString(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox); } KGFGUIUtility.EndHorizontalBox(); KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkBottom, GUILayout.ExpandWidth(true)); { KGFGUIUtility.BeginVerticalPadding(); { if (KGFGUIUtility.Button(KGFGUIUtility.GetHelpIcon(), "documentation", KGFGUIUtility.eStyleButton.eButtonLeft, GUILayout.ExpandWidth(true))) { Application.OpenURL("http://www.kolmich.at/documentation/" + itsOpenModule.GetDocumentationPath()); itsOpenModule = null; } /* * if(KGFGUIUtility.Button("user documentation", KGFGUIUtility.eStyleButton.eButtonMiddle, GUILayout.ExpandWidth(true))) * { * Application.OpenURL("http://www.kolmich.at/documentation/frames.html"); * itsOpenModule = null; * } */ if (KGFGUIUtility.Button(KGFGUIUtility.GetHelpIcon(), "forum", KGFGUIUtility.eStyleButton.eButtonMiddle, GUILayout.ExpandWidth(true))) { Application.OpenURL("http://www.kolmich.at/forum/" + itsOpenModule.GetForumPath()); itsOpenModule = null; } if (KGFGUIUtility.Button(KGFGUIUtility.GetHelpIcon(), "homepage", KGFGUIUtility.eStyleButton.eButtonRight, GUILayout.ExpandWidth(true))) { Application.OpenURL("http://www.kolmich.at"); itsOpenModule = null; } } KGFGUIUtility.EndVerticalPadding(); } KGFGUIUtility.EndHorizontalBox(); } KGFGUIUtility.EndHorizontalPadding(); } KGFGUIUtility.EndVerticalBox(); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); }
/// <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(Editor theEditor, Type theType, Action theHandler) { #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 RenderInspectorErrorChecking(theEditor.target); // 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(); }