public override KGFMessageList Validate() { KGFMessageList aMessageList = new KGFMessageList(); if (itsDataModuleDebugger.itsIconModule == null) { aMessageList.AddWarning("the module icon is missing"); } return(aMessageList); }
/// <summary> /// this class will call the validate method of the inspector /// </summary> /// <param name="theGameObject"></param> public static KGFMessageList ValidateEditor(UnityEngine.Object theObject) { KGFMessageList aMessageList = new KGFMessageList(); string anObjectName = theObject.GetType().ToString(); string aTypeName = anObjectName + "Editor"; Type aType = Type.GetType(aTypeName); if (aType != null) { MethodInfo aMethodInfo = aType.GetMethod("Validate" + aTypeName, System.Reflection.BindingFlags.Static | BindingFlags.Public); if (aMethodInfo != null && aMethodInfo.GetParameters().Length == 1) { object[] aParameters = new object[1]; aParameters[0] = theObject; aMessageList = (KGFMessageList)aMethodInfo.Invoke(null, aParameters); } else { if (!itsAlreadySentWarnings.Contains(aTypeName)) { itsAlreadySentWarnings.Add(aTypeName); aMessageList.AddWarning("static method Validate" + aTypeName + "() not implemented in: " + aTypeName); Debug.LogWarning("static method Validate() not implemented in: " + aTypeName); } } } else { if (!itsAlreadySentWarnings.Contains(aTypeName)) { itsAlreadySentWarnings.Add(aTypeName); aMessageList.AddWarning("type: " + aTypeName + " not implemented."); Debug.LogWarning("type: " + aTypeName + " not implemented."); } } return(aMessageList); }
/// <summary> /// this class will call the validate method of the inspector /// </summary> /// <param name="theGameObject"></param> public static KGFMessageList ValidateEditor(UnityEngine.Object theObject) { KGFMessageList aMessageList = new KGFMessageList(); string anObjectName = theObject.GetType().ToString(); string aTypeName = anObjectName+"Editor"; Type aType = Type.GetType(aTypeName); if(aType != null) { MethodInfo aMethodInfo = aType.GetMethod("Validate"+aTypeName,System.Reflection.BindingFlags.Static | BindingFlags.Public); if(aMethodInfo != null && aMethodInfo.GetParameters().Length == 1) { object[] aParameters = new object[1]; aParameters[0] = theObject; aMessageList = (KGFMessageList)aMethodInfo.Invoke(null,aParameters); } else { if (!itsAlreadySentWarnings.Contains(aTypeName)) { itsAlreadySentWarnings.Add(aTypeName); aMessageList.AddWarning("static method Validate"+aTypeName+"() not implemented in: "+aTypeName); Debug.LogWarning("static method Validate() not implemented in: "+aTypeName); } } } else { if (!itsAlreadySentWarnings.Contains(aTypeName)) { itsAlreadySentWarnings.Add(aTypeName); aMessageList.AddWarning("type: "+aTypeName+" not implemented."); Debug.LogWarning("type: "+aTypeName+" not implemented."); } } return aMessageList; }
public override KGFMessageList Validate() { KGFMessageList aMessageList = new KGFMessageList(); if (itsDataModuleCustomGUI.itsUnknownIcon == null) { aMessageList.AddWarning("the unknown icon is missing"); } if (itsDataModuleCustomGUI.itsModifierKey == itsDataModuleCustomGUI.itsSchortcutKey) { aMessageList.AddInfo("the modifier key is equal to the shortcut key"); } return(aMessageList); }
/// <summary> /// Check this instance for errors /// </summary> /// <returns></returns> public override KGFMessageList Validate () { KGFMessageList aList = new KGFMessageList (); if (("" + itsEventData.itsMethodName).Trim () == string.Empty) { aList.AddError ("itsMethod is empty"); } // find method if (!itsEventData.itsRuntimeObjectSearch) { if (itsEventData.itsObject == null) { aList.AddError ("itsObject == null"); } if (("" + itsEventData.itsComponentName).Trim () == string.Empty) { aList.AddError ("itsScript is empty"); } if (itsEventData.itsObject != null) { MethodInfo aFoundMethod; MonoBehaviour aFoundComponent; if (!FindMethod (itsEventData, out aFoundMethod, out aFoundComponent)) { aList.AddError ("method could not be found"); } } } // search type if (itsEventData.itsRuntimeObjectSearch) { Type aType = itsEventData.GetRuntimeType(); if (aType == null) { aList.AddError("could not find type"); }else { if (aType.IsInterface) { aList.AddWarning("you used an interface, please ensure that the objects you want to call the method on are derrived from KGFObject"); } else { if (!typeof(MonoBehaviour).IsAssignableFrom(aType)) { aList.AddError("type must be derrived from Monobehaviour"); } if (!typeof(KGFObject).IsAssignableFrom(aType)) { aList.AddWarning("please derrive from KGFObject because it will be faster to search"); } } } } // // convert parameters // if (aFoundMethod != null) // { // object [] aParametersList = ConvertParameters (aFoundMethod.GetParameters (), itsParameters); // foreach (object anObject in aParametersList) // { // // Does not work, don't know why // if (anObject == null) // { // aList.AddError("null parameters are not allowed"); // break; // } // } // } return aList; }
/// <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(); }
public override KGFMessageList Validate() { KGFMessageList aMessageList = new KGFMessageList(); if(itsDataModuleCustomGUI.itsUnknownIcon == null) { aMessageList.AddWarning("the unknown icon is missing"); } if(itsDataModuleCustomGUI.itsModifierKey == itsDataModuleCustomGUI.itsSchortcutKey) { aMessageList.AddInfo("the modifier key is equal to the shortcut key"); } return aMessageList; }
public override KGFMessageList Validate() { KGFMessageList aMessageList = new KGFMessageList(); // main RegionError(ref aMessageList,"itsDataModuleMinimap.itsStaticNorth",itsDataModuleMinimap.itsGlobalSettings.itsStaticNorth,0,360); if (itsDataModuleMinimap.itsGlobalSettings.itsTarget == null) { aMessageList.AddError("itsTarget must not be null. Please add a target that is always centered on the minimap (e.g.: the character)."); } // appearance minimap if (itsDataModuleMinimap.itsAppearanceMiniMap.itsMask != null && !GetHasProVersion()) { aMessageList.AddWarning("Masking texture does only work in Unity Pro version. (itsAppearanceMiniMap.itsMask)"); } RegionError(ref aMessageList,"itsAppearanceMiniMap.itsSize",itsDataModuleMinimap.itsAppearanceMiniMap.itsSize,0,1); RegionError(ref aMessageList,"itsAppearanceMiniMap.itsButtonSize",itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonSize,0,1); RegionError(ref aMessageList,"itsAppearanceMiniMap.itsButtonPadding",itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonPadding,0,1); RegionError(ref aMessageList,"itsAppearanceMiniMap.itsScaleArrows",itsDataModuleMinimap.itsAppearanceMiniMap.itsScaleArrows,0,1); RegionError(ref aMessageList,"itsAppearanceMiniMap.itsScaleIcons",itsDataModuleMinimap.itsAppearanceMiniMap.itsScaleIcons,0,1); RegionError(ref aMessageList,"itsAppearanceMiniMap.itsRadiusArrows",itsDataModuleMinimap.itsAppearanceMiniMap.itsRadiusArrows,0,1); PositiveError(ref aMessageList,"itsAppearanceMiniMap.itsBackgroundBorder",itsDataModuleMinimap.itsAppearanceMiniMap.itsBackgroundBorder); if (itsDataModuleMinimap.itsAppearanceMiniMap.itsBackground == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsBackground)"); } if (itsDataModuleMinimap.itsAppearanceMiniMap.itsButton == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsButton)"); } if (itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonDown == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsButtonDown)"); } if (itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonHover == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsButtonHover)"); } if (itsDataModuleMinimap.itsAppearanceMiniMap.itsIconZoomIn == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsIconZoomIn)"); } if (itsDataModuleMinimap.itsAppearanceMiniMap.itsIconZoomOut == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsIconZoomOut)"); } if (itsDataModuleMinimap.itsAppearanceMiniMap.itsIconZoomLock == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsIconZoomLock)"); } if (itsDataModuleMinimap.itsAppearanceMiniMap.itsIconFullscreen == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsIconFullscreen)"); } // appearance map RegionError(ref aMessageList,"itsAppearanceMap.itsButtonSize",itsDataModuleMinimap.itsAppearanceMap.itsButtonSize,0,1); RegionError(ref aMessageList,"itsAppearanceMap.itsButtonPadding",itsDataModuleMinimap.itsAppearanceMap.itsButtonPadding,0,1); RegionError(ref aMessageList,"itsAppearanceMap.itsButtonSpace",itsDataModuleMinimap.itsAppearanceMap.itsButtonSpace,0,1); RegionError(ref aMessageList,"itsAppearanceMap.itsScaleIcons",itsDataModuleMinimap.itsAppearanceMap.itsScaleIcons,0,1); PositiveError(ref aMessageList,"itsAppearanceMap.itsBackgroundBorder",itsDataModuleMinimap.itsAppearanceMap.itsBackgroundBorder); if (itsDataModuleMinimap.itsGlobalSettings.itsColorAll != Color.white && !GetHasProVersion()) { aMessageList.AddError("itsColorAll does only work in Unity Pro version. (itsColorAll)"); } if (itsDataModuleMinimap.itsAppearanceMap.itsMask != null && !GetHasProVersion()) { aMessageList.AddWarning("Masking texture does only work in Unity Pro version. (itsAppearanceMap.itsMask)"); } if (itsDataModuleMinimap.itsAppearanceMap.itsButton == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsButton)"); } if (itsDataModuleMinimap.itsAppearanceMap.itsButtonDown == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsButtonDown)"); } if (itsDataModuleMinimap.itsAppearanceMap.itsButtonHover == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsButtonHover)"); } if (itsDataModuleMinimap.itsAppearanceMap.itsIconZoomIn == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsIconZoomIn)"); } if (itsDataModuleMinimap.itsAppearanceMap.itsIconZoomOut == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsIconZoomOut)"); } if (itsDataModuleMinimap.itsAppearanceMap.itsIconZoomLock == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsIconZoomLock)"); } if (itsDataModuleMinimap.itsAppearanceMap.itsIconFullscreen == null) { aMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsIconFullscreen)"); } // fog-of-war PositiveError(ref aMessageList,"itsFogOfWar.itsResolutionX",itsDataModuleMinimap.itsFogOfWar.itsResolutionX); PositiveError(ref aMessageList,"itsFogOfWar.itsResolutionY",itsDataModuleMinimap.itsFogOfWar.itsResolutionY); PositiveError(ref aMessageList,"itsFogOfWar.itsRevealDistance",itsDataModuleMinimap.itsFogOfWar.itsRevealDistance); PositiveError(ref aMessageList,"itsFogOfWar.itsRevealedFullDistance",itsDataModuleMinimap.itsFogOfWar.itsRevealedFullDistance); if (itsDataModuleMinimap.itsFogOfWar.itsRevealedFullDistance > itsDataModuleMinimap.itsFogOfWar.itsRevealDistance) { aMessageList.AddError("itsFogOfWar.itsRevealDistance must be bigger than itsFogOfWar.itsRevealedFullDistance"); } // zoom minimap PositiveError(ref aMessageList,"itsZoomMiniMap.itsZoomChangeValue",itsDataModuleMinimap.itsZoomMiniMap.itsZoomChangeValue); PositiveError(ref aMessageList,"itsZoomMiniMap.itsZoomMax",itsDataModuleMinimap.itsZoomMiniMap.itsZoomMax); PositiveError(ref aMessageList,"itsZoomMiniMap.itsZoomMin",itsDataModuleMinimap.itsZoomMiniMap.itsZoomMin); PositiveError(ref aMessageList,"itsZoomMiniMap.itsZoomStartValue",itsDataModuleMinimap.itsZoomMiniMap.itsZoomStartValue); if (itsDataModuleMinimap.itsZoomMiniMap.itsZoomMin > itsDataModuleMinimap.itsZoomMiniMap.itsZoomMax) { aMessageList.AddError("itsZoomMiniMap.itsZoomMax must be bigger than itsZoomMiniMap.itsZoomMin"); } if (itsDataModuleMinimap.itsZoomMiniMap.itsZoomStartValue < itsDataModuleMinimap.itsZoomMiniMap.itsZoomMin || itsDataModuleMinimap.itsZoomMiniMap.itsZoomStartValue > itsDataModuleMinimap.itsZoomMiniMap.itsZoomMax) { aMessageList.AddError("itsZoomMiniMap.itsZoomStartValue has to be between itsZoomMiniMap.itsZoomMin and itsZoomMiniMap.itsZoomMin"); } // zoom map PositiveError(ref aMessageList,"itsZoomMap.itsZoomChangeValue",itsDataModuleMinimap.itsZoomMap.itsZoomChangeValue); PositiveError(ref aMessageList,"itsZoomMap.itsZoomMax",itsDataModuleMinimap.itsZoomMap.itsZoomMax); PositiveError(ref aMessageList,"itsZoomMap.itsZoomMin",itsDataModuleMinimap.itsZoomMap.itsZoomMin); PositiveError(ref aMessageList,"itsZoomMap.itsZoomStartValue",itsDataModuleMinimap.itsZoomMap.itsZoomStartValue); if (itsDataModuleMinimap.itsZoomMap.itsZoomMin > itsDataModuleMinimap.itsZoomMap.itsZoomMax) { aMessageList.AddError("itsZoomMap.itsZoomMax must be bigger than itsZoomMap.itsZoomMin"); } if (itsDataModuleMinimap.itsZoomMap.itsZoomStartValue < itsDataModuleMinimap.itsZoomMap.itsZoomMin || itsDataModuleMinimap.itsZoomMap.itsZoomStartValue > itsDataModuleMinimap.itsZoomMap.itsZoomMax) { aMessageList.AddError("itsZoomMap.itsZoomStartValue has to be between itsZoomMap.itsZoomMin and itsZoomMap.itsZoomMin"); } // viewport if (itsDataModuleMinimap.itsViewport.itsActive && itsDataModuleMinimap.itsViewport.itsCamera == null) { aMessageList.AddError("Active viewport needs a camera (itsViewport.itsCamera)"); } if (itsDataModuleMinimap.itsViewport.itsActive && itsDataModuleMinimap.itsGlobalSettings.itsOrientation == KGFMapSystemOrientation.XYSideScroller) { aMessageList.AddError("Viewport display is not supported in SideScroller mode (itsViewport.itsCamera)"); } if (itsDataModuleMinimap.itsViewport.itsColor.a == 0) { aMessageList.AddError("Viewport will be invisible if itsColor.a == 0"); } // photo if (itsDataModuleMinimap.itsPhoto.itsTakePhoto && itsDataModuleMinimap.itsPhoto.itsPhotoLayers == 0) { aMessageList.AddError("itsPhoto.itsPhotoLayers has to contain some layers for the photo not to be empty"); } // user flags if (itsDataModuleMinimap.itsUserFlags.itsActive) { } // layer check if (LayerMask.NameToLayer(itsLayerName) < 0) { aMessageList.AddError(string.Format("The map system needs a layer with the name '{0}'",itsLayerName)); } // if (itsDataModuleMinimap.itsGlobalSettings.itsRenderLayers == 0) // { // aMessageList.AddError(string.Format("itsRenderLayer is not allowed to be Nothing")); // } // panning if (itsDataModuleMinimap.itsPanning.itsActive && itsDataModuleMinimap.itsPanning.itsUseBounds && itsDataModuleMinimap.itsPanning.itsBoundsLayers == 0) { aMessageList.AddError("itsPanning.itsBoundsLayers has to contain some layers for the panning bounds to work"); } if(itsDataModuleMinimap.itsShaders.itsShaderMapIcon == null) { aMessageList.AddError(string.Format("itsDataModuleMinimap.itsShaders.itsShaderMapIcon is null")); } if(itsDataModuleMinimap.itsShaders.itsShaderPhotoPlane == null) { aMessageList.AddError(string.Format("itsDataModuleMinimap.itsShaders.itsShaderPhotoPlane is null")); } if(itsDataModuleMinimap.itsShaders.itsShaderMapMask == null) { aMessageList.AddError(string.Format("itsDataModuleMinimap.itsShaders.itsShaderMapMask is null")); } if(itsDataModuleMinimap.itsFogOfWar.itsActive == true && itsDataModuleMinimap.itsShaders.itsShaderFogOfWar == null) { aMessageList.AddWarning(string.Format("itsDataModuleMinimap.itsShaders.itsShaderFogOfWar is null, fog of war will not work")); } // Transform aTransform = transform.Find("measure_cube"); // if(itsDataModuleMinimap.itsPhoto.itsTakePhoto == true && aTransform == null) // { // aMessageList.AddError(string.Format("please press the RecalcPhotoArea button")); // } return aMessageList; }
/// <summary> /// Check this instance for errors /// </summary> /// <returns></returns> public override KGFMessageList Validate() { KGFMessageList aList = new KGFMessageList(); if (("" + itsEventData.itsMethodName).Trim() == string.Empty) { aList.AddError("itsMethod is empty"); } // find method if (!itsEventData.itsRuntimeObjectSearch) { if (itsEventData.itsObject == null) { aList.AddError("itsObject == null"); } if (("" + itsEventData.itsComponentName).Trim() == string.Empty) { aList.AddError("itsScript is empty"); } if (itsEventData.itsObject != null) { MethodInfo aFoundMethod; MonoBehaviour aFoundComponent; if (!FindMethod(itsEventData, out aFoundMethod, out aFoundComponent)) { aList.AddError("method could not be found"); } } } // search type if (itsEventData.itsRuntimeObjectSearch) { Type aType = itsEventData.GetRuntimeType(); if (aType == null) { aList.AddError("could not find type"); } else { if (aType.IsInterface) { aList.AddWarning("you used an interface, please ensure that the objects you want to call the method on are derrived from KGFObject"); } else { if (!typeof(MonoBehaviour).IsAssignableFrom(aType)) { aList.AddError("type must be derrived from Monobehaviour"); } if (!typeof(KGFObject).IsAssignableFrom(aType)) { aList.AddWarning("please derrive from KGFObject because it will be faster to search"); } } } } // // convert parameters // if (aFoundMethod != null) // { // object [] aParametersList = ConvertParameters (aFoundMethod.GetParameters (), itsParameters); // foreach (object anObject in aParametersList) // { // // Does not work, don't know why // if (anObject == null) // { // aList.AddError("null parameters are not allowed"); // break; // } // } // } return(aList); }