Пример #1
0
    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    public KGFMessageList Validate()
    {
        KGFMessageList aMessageList = new KGFMessageList ();

        //target
        if (itsTarget.itsTarget == null)
        {
            aMessageList.AddError ("itsTarget should not be empty");
        }
        if (itsTarget.itsPositionSpeed <= 0)
        {
            aMessageList.AddError ("itsLinkedTargetPositionSpeed has invalid value, has to be > 0");
        }
        if (itsTarget.itsRotationSpeed <= 0)
        {
            aMessageList.AddError ("itsLinkedTargetRotationSpeed has invalid value, has to be > 0");
        }

        //Zoom
        if (itsZoom.itsZoomSpeed <= 0)
        {
            aMessageList.AddError ("itsZoomSpeed has invalid value, has to be > 0");
        }
        if (itsZoom.itsStartValue < itsZoom.itsMinLimit)
        {
            aMessageList.AddError ("itsStartZoom should not be smaller than itsMinZoom");
        }
        if (itsZoom.itsStartValue > itsZoom.itsMaxLimit)
        {
            aMessageList.AddError ("itsStartZoom should not be bigger than itsMaxZoom");
        }
        if (itsZoom.itsMinLimit > itsZoom.itsMaxLimit)
        {
            aMessageList.AddError ("itsMinZoom should not be bigger than itsMaxZoom");
        }
        if (itsZoom.itsMaxLimit < itsZoom.itsMinLimit)
        {
            aMessageList.AddError ("itsMaxZoom should not be smaller than itsMinZoom");
        }
        if (itsZoom.itsMinLimit < 0)
        {
            aMessageList.AddError ("itsMinZoom should not be smaller than 0");
        }

        //Rotation Up Down
        if (itsRotation.itsVertical.itsDownLimit < 0)
        {
            aMessageList.AddError ("itsRotation itsUpDown itsDownLimit should not be smaller than 0");
        }
        if (itsRotation.itsVertical.itsUpLimit < 0)
        {
            aMessageList.AddError ("itsRotation itsUpDown itsUpLimit should not be smaller than 0");
        }

        //Rotation Left Right
        if (itsRotation.itsHorizontal.itsLeftLimit < 0)
        {
            aMessageList.AddError ("itsRotation itsLeftRight itsLeftLimit should not be smaller than 0");
        }
        if (itsRotation.itsHorizontal.itsRightLimit < 0)
        {
            aMessageList.AddError ("itsRotation itsLeftRight itsRightLimit should not be smaller than 0");
        }

        //Lookat
        if (itsLookat.itsLookatSpeed <= 0)
        {
            aMessageList.AddError ("itsLookatSpeed has invalid value, has to be > 0");
        }
        if (itsLookat.itsEnable)
        {
            if(itsLookat.itsLookatTarget == null)
            {
                aMessageList.AddError ("itsLookat is Enabled but Lookat target has not been assigned");
            }
            if(itsLookat.itsUpVectorSource == null)
            {
                aMessageList.AddError ("itsLookat is Enabled but up vector source has not been assigned");
            }
        }

        aMessageList.AddMessages(KGFOrbitCam.ValidateControls(itsRotation.itsHorizontal.itsControls,"itsRotation.itsHorizontal.itsControls").GetAllMessagesArray());
        aMessageList.AddMessages(KGFOrbitCam.ValidateControls(itsRotation.itsVertical.itsControls,"itsRotation.itsVertical.itsControls").GetAllMessagesArray());
        aMessageList.AddMessages(KGFOrbitCam.ValidateControls(itsZoom.itsControls,"itsZoom.itsControls").GetAllMessagesArray());
        aMessageList.AddMessages(KGFOrbitCam.ValidateControls(itsPanning.itsForwardBackward.itsControls,"itsPanning.itsForwardBackward.itsControls").GetAllMessagesArray());
        aMessageList.AddMessages(KGFOrbitCam.ValidateControls(itsPanning.itsLeftRight.itsControls,"itsPanning.itsLeftRight.itsControls").GetAllMessagesArray());
        aMessageList.AddMessages(KGFOrbitCam.ValidateControls(itsPanning.itsUpDown.itsControls,"itsPanning.itsUpDown.itsControls").GetAllMessagesArray());

        return aMessageList;
    }
    /// <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 KGFMessageList Validate()
    {
        KGFMessageList aMessageList = new KGFMessageList();

        //Orbiter
        if (itsOrbitCam.itsOrbitCam == null)
        {
            aMessageList.AddError("itsOrbitCam should not be empty");
        }

        //Root
        if (itsTarget.itsTarget == null)
        {
            aMessageList.AddError("itsTarget should not be empty");
        }
        if (itsTarget.itsTarget == this.gameObject)
        {
            aMessageList.AddError("itsTarget cannot be th KGFOrbitCamSetting itself");
        }
        if (itsTarget.itsPositionSpeed <= 0)
        {
            aMessageList.AddError("itsLinkedTargetPositionSpeed has invalid value, has to be > 0");
        }
        if (itsTarget.itsRotationSpeed <= 0)
        {
            aMessageList.AddError("itsLinkedTargetRotationSpeed has invalid value, has to be > 0");
        }

        //Lookat
        if (itsLookat.itsLookatSpeed <= 0)
        {
            aMessageList.AddError("itsLookatSpeed has invalid value, has to be > 0");
        }
        if (itsLookat.itsEnable)
        {
            if (itsLookat.itsLookatTarget == null)
            {
                aMessageList.AddError("itsLookat is Enabled but Lookat target has not been assigned");
            }
            if (itsLookat.itsUpVectorSource == null)
            {
                aMessageList.AddError("itsLookat is Enabled but up vector source has not been assigned");
            }
        }


        //Zoom
        if (itsZoom.itsZoomSpeed <= 0)
        {
            aMessageList.AddError("itsZoomSpeed has invalid value, has to be > 0");
        }
        if (itsZoom.itsStartValue < itsZoom.itsMinLimit)
        {
            aMessageList.AddError("itsStartZoom should not be smaller than itsMinZoom");
        }
        if (itsZoom.itsStartValue > itsZoom.itsMaxLimit)
        {
            aMessageList.AddError("itsStartZoom should not be bigger than itsMaxZoom");
        }
        if (itsZoom.itsMinLimit > itsZoom.itsMaxLimit)
        {
            aMessageList.AddError("itsMinZoom should not be bigger than itsMaxZoom");
        }
        if (itsZoom.itsMaxLimit < itsZoom.itsMinLimit)
        {
            aMessageList.AddError("itsMaxZoon should not be smaller than itsMinZoom");
        }
        if (itsZoom.itsMinLimit < 0)
        {
            aMessageList.AddError("itsMinZoon should not be smaller than 0");
        }

        //Rotation Up Down
        if (itsRotation.itsVertical.itsDownLimit < 0)
        {
            aMessageList.AddError("itsRotation itsUpDown itsDownLimit should not be smaller than 0");
        }
        if (itsRotation.itsVertical.itsUpLimit < 0)
        {
            aMessageList.AddError("itsRotation itsUpDown itsUpLimit should not be smaller than 0");
        }

        //Rotation Left Right
        if (itsRotation.itsHorizontal.itsLeftLimit < 0)
        {
            aMessageList.AddError("itsRotation itsLeftRight itsLeftLimit should not be smaller than 0");
        }
        if (itsRotation.itsHorizontal.itsRightLimit < 0)
        {
            aMessageList.AddError("itsRotation itsLeftRight itsRightLimit should not be smaller than 0");
        }

        aMessageList.AddMessages(KGFOrbitCam.ValidateControls(itsRotation.itsHorizontal.itsControls, "itsRotation.itsHorizontal.itsControls").GetAllMessagesArray());
        aMessageList.AddMessages(KGFOrbitCam.ValidateControls(itsRotation.itsVertical.itsControls, "itsRotation.itsVertical.itsControls").GetAllMessagesArray());
        aMessageList.AddMessages(KGFOrbitCam.ValidateControls(itsZoom.itsControls, "itsZoom.itsControls").GetAllMessagesArray());
        aMessageList.AddMessages(KGFOrbitCam.ValidateControls(itsPanning.itsForwardBackward.itsControls, "itsPanning.itsForwardBackward.itsControls").GetAllMessagesArray());
        aMessageList.AddMessages(KGFOrbitCam.ValidateControls(itsPanning.itsLeftRight.itsControls, "itsPanning.itsLeftRight.itsControls").GetAllMessagesArray());
        aMessageList.AddMessages(KGFOrbitCam.ValidateControls(itsPanning.itsUpDown.itsControls, "itsPanning.itsUpDown.itsControls").GetAllMessagesArray());

        return(aMessageList);
    }