Beispiel #1
0
    public override void OnGUI(Rect position, SerializedProperty a_Property, GUIContent a_Label)
    {
        position.height = EditorHelp.c_LineHeight;
        EditorGUI.BeginProperty(position, a_Label, a_Property);

        SerializedProperty foldOutProperty = a_Property.FindPropertyRelative("m_IsFoldingOut");
        SerializedProperty prefabProperty  = a_Property.FindPropertyRelative("m_AbilityModulePrefab");
        AbilityModule      prefab          = null;
        string             nameString      = "Ability slot empty";

        if (prefabProperty.objectReferenceValue != null)
        {
            prefab     = prefabProperty.objectReferenceValue as AbilityModule;
            nameString = prefab.GetName();
        }
        foldOutProperty.boolValue = EditorGUI.Foldout(position, foldOutProperty.boolValue, nameString, true);

        Rect pos = position;

        if (foldOutProperty.boolValue)
        {
            EditorGUI.indentLevel++;
            EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_AbilityModulePrefab", ref pos, "", "Prefab");
            if (prefabProperty.objectReferenceValue != null)
            {
                if (EditorHelp.PropertyDrawerButton("Edit", ref pos))
                {
                    Selection.activeGameObject = prefab.gameObject;
                }
            }
            EditorGUI.indentLevel--;
        }

        EditorGUI.EndProperty();
    }
Beispiel #2
0
 void OnInspectorUpdate()
 {
     //	Debug.Log( EditorHelp.GetFrame());
     EditorHelp.Reload();
     EditorHelp.RenewAc();
     //ReloadAniEventList();
     Repaint();
 }
Beispiel #3
0
 private new void OnEnable()
 {
     editorHelp = new EditorHelp()
     {
         valueTypes        = new Type[] {},
         valueDescriptions = new string[] {}
     };
 }
Beispiel #4
0
        private new void OnEnable()
        {
            agentsContexts = new Dictionary <Agent, Context>();

            editorHelp = new EditorHelp()
            {
                valueTypes        = new Type[] { },
                valueDescriptions = new string[] { }
            };
        }
Beispiel #5
0
        private new void OnEnable()
        {
            agentsContexts = new Dictionary <Agent, Context>();

            editorHelp = new EditorHelp()
            {
                valueTypes        = new Type[] { typeof(MinMaxFloatAT) },
                valueDescriptions = new string[] { "Movement Speed" }
            };
        }
Beispiel #6
0
        private new void OnEnable()
        {
            agentsContexts = new Dictionary <Agent, Context>();

            editorHelp = new EditorHelp()
            {
                valueTypes        = new Type[] { typeof(EnumStringAT) },
                valueDescriptions = new string[] { "Animation Trigger Param Name" }
            };
        }
Beispiel #7
0
    static void Init()
    {
        //ani_events=new List<AnimationEvent>();
        AnimaEditor window = (AnimaEditor)EditorWindow.GetWindow(typeof(AnimaEditor));

        EditorHelp.InitEditorResource();
        //window.position = new Rect(0,0,150,30);
        window.title = "动画事件面板";

        //window.Show();
        //window.autoRepaintOnSceneChange=true;
    }
Beispiel #8
0
        private new void OnEnable()
        {
            agentsContexts = new Dictionary <Agent, Context>();

            editorHelp = new EditorHelp()
            {
                valueTypes             = new Type[] { typeof(MinMaxFloatAT) },
                valueDescriptions      = new string[] { "Movement Speed" },
                requiredAttributeTypes = new Type[] { typeof(MinMaxFloatAT) },
                requiredDescriptions   = new string[] { "Energy - Only required if Reduce Energy is selected." },
            };
        }
    public override void OnGUI(Rect position, SerializedProperty a_Property, GUIContent a_Label)
    {
        position.height = EditorHelp.c_LineHeight;
        EditorGUI.BeginProperty(position, a_Label, a_Property);

        SerializedProperty foldOutProperty = a_Property.FindPropertyRelative("m_IsFoldingOut");
        string             nameString      = a_Property.FindPropertyRelative("m_Name").stringValue;

        if (nameString == "")
        {
            nameString = "<InputName missing>";
        }

        foldOutProperty.boolValue = EditorGUI.Foldout(position, foldOutProperty.boolValue, nameString, true);

        Rect pos = position;

        if (foldOutProperty.boolValue)
        {
            EditorGUI.indentLevel++;
            EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_Name", ref pos, "Name of this input, as referenced in code");
            EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_InputType", ref pos, "Is this input a button (or key), or directional (analogue stick, arrow keys, WASD)?");

            InputElement.InputType type = (InputElement.InputType)a_Property.FindPropertyRelative("m_InputType").enumValueIndex;
            switch (type)
            {
            case InputElement.InputType.Button:
            {
                EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_UnityInputType", ref pos, "Is this a button, or can it be triggered by an axis as well (triggers on a gamepad for example)");
                if (a_Property.FindPropertyRelative("m_UnityInputType").enumValueIndex != 0)
                {
                    EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_UnityAxisRecognition", ref pos, "If this button can be triggered by an axis, should it trigger if the axis value is: positive only, negative only, or not zero");
                }
                EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_ButtonName", ref pos, "In Unity's input manager, what is the name of the button/axis that this input uses?");
            }
            break;

            case InputElement.InputType.Direction:
            {
                EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_HorizontalAxisName", ref pos, "In Unity's input manager, what is the name of the axis that this input uses for its horizontal value?");
                EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_VerticalAxisName", ref pos, "In Unity's input manager, what is the name of the axis that this input uses for its vertical value?");
                EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_DirectionThreshold", ref pos, "In the case of analogue input, how far should the input be pushed before a direction is recognized? For example: how far should an analogue stick be pulled down before it registers as a crouch command");
            }
            break;
            }
            EditorGUI.indentLevel--;
        }

        EditorGUI.EndProperty();
    }
Beispiel #10
0
    /// <summary>
    /// 重读事件列表
    /// </summary>
    void ReloadAniEventList()
    {
        if (ani_clip != null)
        {
            Debug.Log("reload");
            AnimationEvent[] ae = (AnimationUtility.GetAnimationEvents(ani_clip));
            if (ae != null)
            {
                ani_events = EditorHelp.CopyAnimaEventArrayToList(ae);
            }

            fps_sec   = 1f / ani_clip.frameRate;
            max_frame = Mathf.CeilToInt(ani_clip.length * ani_clip.frameRate);
        }
    }
    public static void ShowTab(CharacterControllerBase a_CharacterController)
    {
        if (a_CharacterController == null)
        {
            GUILayout.Label("CharacterController script not found on object", EditorStyles.boldLabel);
            return;
        }
        CapsuleMovingColliderSolver movingColliderSolver = a_CharacterController.GetComponent <CapsuleMovingColliderSolver>();

        if (movingColliderSolver)
        {
            SerializedObject solverObject = new SerializedObject(movingColliderSolver);
            EditorGUI.BeginChangeCheck();

            float prevLabelWidth = EditorGUIUtility.labelWidth;
            EditorGUIUtility.labelWidth += 120.0f;

            GUILayout.Label("Handling moving colliders", EditorStyles.boldLabel);
            GUILayout.Space(4.0f);

            EditorHelp.SerializeRelativeField(solverObject, "m_ApplyLastMovementAsVelocity", "Should the character inherit velocity from the moving object it was connected with, if the character loses connection with that object? For example: If the character jumps from a moving platform, should it keep the velocity of the moving platform", "Inherit velocity from moving platforms");
            if (solverObject.FindProperty("m_ApplyLastMovementAsVelocity").boolValue)
            {
                EditorHelp.SerializeRelativeField(solverObject, "m_DisableDownwardsLastMovement", "If the character inherits velocity from the moving object, should it prevent getting any downwards velocity? If the character is jumping from a platform that is moving down, should it ignore the downward velocity (checked), or should it also inherit that (unchecked)", "Inherit downward velocity or ignore it");
            }
            EditorHelp.SerializeRelativeField(solverObject, "m_UseEscapeAcceleration", "Should this character detach from a moving platform if the acceleration is too large? For example: if a character is standing on a platform which suddenly drops down, should the character detach from that platform (checked), or should the character stick to that platform (unchecked). Does not work if the platform is (partially) moving in the direction of the character (if a platform the character is standing on suddenly moves up, the character will stay connected)", "Detach from fast moving platforms");
            if (solverObject.FindProperty("m_UseEscapeAcceleration").boolValue)
            {
                EditorHelp.SerializeRelativeField(solverObject, "m_EscapeAcceleration", "If the above is checked, what is the acceleration needed for the character to detach? If the character is standing on a platform that moves away, how fast should it drop before the character detaches?", "Acceleration needed to detach");
            }

            EditorGUIUtility.labelWidth = prevLabelWidth;

            if (EditorGUI.EndChangeCheck())
            {
                solverObject.ApplyModifiedProperties();
            }
        }
        else
        {
            GUILayout.Label("CapsuleMovingColliderSolver script not found on object", EditorStyles.boldLabel);
        }
    }
    public static void ShowTab(CharacterControllerBase a_CharacterController)
    {
        if (Application.isPlaying)
        {
            GUILayout.Label("Abilities cannot be edited during play!", EditorStyles.boldLabel);
            return;
        }
        if (a_CharacterController == null)
        {
            GUILayout.Label("CharacterController script not found on object", EditorStyles.boldLabel);
            return;
        }
        AbilityModuleManager abilityModuleManager = a_CharacterController.GetAbilityModuleManager();

        if (abilityModuleManager)
        {
            SerializedObject abilityManagerObject = new SerializedObject(abilityModuleManager);
            EditorGUI.BeginChangeCheck();

            float prevLabelWidth = EditorGUIUtility.labelWidth;
            //EditorGUIUtility.labelWidth += 50.0f;

            GUILayout.Label("List of abilities", EditorStyles.boldLabel);
            GUILayout.Space(4.0f);

            SerializedProperty array = abilityManagerObject.FindProperty("m_AbilitySlots");
            if (array != null)
            {
                EditorHelp.SerializeArray(array);
            }

            EditorGUIUtility.labelWidth = prevLabelWidth;

            if (EditorGUI.EndChangeCheck())
            {
                abilityManagerObject.ApplyModifiedProperties();
            }
        }
        else
        {
            GUILayout.Label("AbilityModuleManager script not found on object", EditorStyles.boldLabel);
        }
    }
    public static void ShowTab(CharacterControllerBase a_CharacterController)
    {
        if (a_CharacterController == null)
        {
            GUILayout.Label("CharacterController script not found on object", EditorStyles.boldLabel);
            return;
        }
        PlayerInput playerInput = a_CharacterController.GetComponent <PlayerInput>();

        if (playerInput)
        {
            SerializedObject inputObject = new SerializedObject(playerInput);
            EditorGUI.BeginChangeCheck();

            float prevLabelWidth = EditorGUIUtility.labelWidth;
            EditorGUIUtility.labelWidth += 15.0f;

            GUILayout.Label("List of inputs", EditorStyles.boldLabel);
            GUILayout.Space(4.0f);

            SerializedProperty array = inputObject.FindProperty("m_Inputs");
            if (array != null)
            {
                EditorHelp.SerializeArray(array);
            }

            EditorGUIUtility.labelWidth = prevLabelWidth;

            if (EditorGUI.EndChangeCheck())
            {
                inputObject.ApplyModifiedProperties();
            }
        }
        else
        {
            GUILayout.Label("PlayerInput script not found on object", EditorStyles.boldLabel);
        }
    }
Beispiel #14
0
    void OnGUI()
    {
        CheckSelection();

        float d = 20;
        float dh = d + 1;
        float adx, ady; adx = ady = 0;

        Vector2 spt_zoom = new Vector2(24, 24);

        adx = 0;
        if (GUI.Button(new Rect(adx, ady, 150, d), "格式化动画时间始末"))
        {
            foreach (AnimationClip ac in ac_rnc_lstt)
            {
                EditorHelp.CheckAnimationClipEvent(ac);
            }
        }

        adx += 200;
        ady += dh;
        adx  = 0;

        GUI.BeginGroup(new Rect(adx, ady, position.width, position.height));
        for (int i = 0; i < s_rnc_lstt.Count; i++)
        {
            if (GUI.Button(new Rect(0, i * spt_zoom.y, spt_zoom.x, spt_zoom.y), ""))
            {
                effAni.runtimeAnimatorController = Game.EAtr(s_rnc_lstt[i]);
                Wilrnc_lstelection(effAni.gameObject);
            }
            EditorHelp.EditorDrawSprite(new Rect(0, i * spt_zoom.y, spt_zoom.x, spt_zoom.y), spt_dic[s_rnc_lstt[i]]);
        }

        GUI.EndGroup();
    }
Beispiel #15
0
    void OnGUI()
    {
        //GUILayout.Label(EditorWindow.focusedWindow.ToString());
        //AnimationUtility.onCurveWasModified.BeginInvoke(ani_clip,null,null,null,null).IsCompleted
        if (AnimationUtility.InAnimationMode())
        {
            //aw.time;

            //AnimationWindow aw = (AnimationWindow)EditorWindow.GetWindow (typeof (AnimationWindow));
            //AnimationWindow aw=GetWindow<AnimationWindow>();
            //Debug.Log(aw.chosenClip);

            /*
             * if(GUIUtility.hotControl!=0)
             * {
             *      AnimationClip ac=GUIUtility.GetStateObject(typeof(AnimationClip),GUIUtility.hotControl) as AnimationClip;
             *      if(ac!=null)Debug.Log(ac.name);
             *
             *      //Debug.Log(Event.current.type);
             *      Debug.Log("id: " + GUIUtility.hotControl);
             *      //Debug.Log(GUIUtility.GetControlID(FocusType.Passive));
             * //	Event.current.Use();
             * }*/
            //AnimationUtility.
        }

        //	Debug.Log( Event.current.ToString());
        float ady = 4;
        float adx = 4;



        if (ani_clip)
        {
            if (ani_events == null)
            {
                ReloadAniEventList();
            }

            if (GUI.Button(new Rect(adx, ady, 48, 20), "格式化"))
            {
                CheckEventNT();
            }
            adx += 48;
            //GUI.Label(new Rect(adx,ady,position.width-4-adx,20),EditorWindow.focusedWindow.title);

            //if(EditorWindow.focusedWindow.title=="UnityEditor.AnimationWindow")
            {
                if (Event.current.isMouse && Event.current.button == 0 && Event.current.type == EventType.MouseDown)
                {
                    EditorHelp.Reload();
                    EditorHelp.GetAniWin();
                }


                //typeof(UnityEdit or.UnityEditor.AnimationWindow).type

                //Debug.Log(EditorWindow.focusedWindow.GetType().Namespace);
                //Debug.Log(EditorWindow.focusedWindow.GetType().IsPublic);
                //Debug.Log(this.GetType().Namespace);
                //Debug.Log(this.GetType().FullName);
            }

            adx = 4; ady = 24;
            GUI.Label(new Rect(adx, ady, position.width - 4 - adx, 20), "剪辑:\t" + ani_clip.name, EditorStyles.largeLabel); //adx+=42;
            //ani_clip.name=GUI.TextField(new Rect(adx,ady,position.width-4-adx,18),ani_clip.name,EditorStyles.largeLabel);
            ady += 20; adx = 4;
            GUI.Label(new Rect(adx, ady, 36, 20), "帧率:\t", EditorStyles.largeLabel); adx += 36;
            string rate = GUI.TextField(new Rect(adx, ady, 32, 18), ani_clip.frameRate.ToString(), EditorStyles.largeLabel);
            float  rt   = 0;
            if (float.TryParse(rate, out rt))
            {
                ani_clip.frameRate = rt;
            }
            adx += 36;          //ady+=20;

            GUI.Label(new Rect(adx, ady, position.width - 4 - adx, 20), "长度:" + ani_clip.length.ToString("f2") + "s\t" + max_frame + "帧" + "\t循环:" + ani_clip.isLooping + "_" + ani_clip.wrapMode, EditorStyles.largeLabel);
            adx = 4; ady += 20;
            //GUI.Label(new Rect(adx,ady,80,20),"平均持续时间:"+ani_clip.averageDuration,EditorStyles.largeLabel);
            //GUI.Label(new Rect(adx,ady,80,20),"总帧:"+max_frame,EditorStyles.largeLabel);adx=4;ady+=20;
            //GUI.Label(new Rect(adx,ady,80,20),"角速率 :"+ani_clip.averageAngularSpeed,EditorStyles.largeLabel);adx+=80;
            //GUI.Label(new Rect(adx,ady,200,20),"平均速率:"+ani_clip.averageSpeed,EditorStyles.largeLabel);ady+=20;
            //GUI.Toggle(new Rect(adx,ady,200,20),ani_clip.isLooping,"循环播放");
            //GUI.Label(new Rect(adx,ady,120,20),);adx=4;
            ady += 24;

            EditorHelp.DrawXLine(new Rect(adx, ady + 3, position.width - 4 - adx, 1), new Color(1, 1, 1, 0.3f));
            int   num = max_frame % 60;
            float aex = (position.width - 8 - adx) / num;

            for (int i = 0; i < num + 1; i++)
            {
                EditorHelp.DrawYLine(new Rect(adx, ady + 4, 1, (i % 5 == 0)?16:8), new Color(1, 1, 1, 0.5f));
                adx += aex;
            }

            GUI.contentColor = Color.yellow;
            adx = aex * EditorHelp.frame + 4;
            EditorHelp.DrawYLine(new Rect(adx, ady + 4, 1, 11), Color.yellow);
            string str = (EditorHelp.frame) + "F";
            //float exlx= ((aex+8+str.Length*8>position.width)?position.width-str.Length*8-4:aex+4);
            GUI.Label(new Rect(adx, ady - 24, 36, 14), str, EditorStyles.miniLabel);

            str = ((EditorHelp.frame / ((float)max_frame)) * ani_clip.length).ToString("f2") + "s";
            //exlx= ((aex+8+str.Length*6>position.width)?position.width-str.Length*6-4:aex+4);
            GUI.Label(new Rect(adx, ady + 24, 36, 14), str, EditorStyles.miniLabel);
            GUI.contentColor = Color.white;
            adx = 4;

            float exw = 36;
            for (int i = 0; i < ani_events.Count; i++)
            {
                AnimationEvent ae = ani_events[i];

                aex = (ae.time / ani_clip.length) * (position.width - 8 - adx);
                EditorHelp.DrawYLine(new Rect(aex + 4, ady + 4, 1, 18), new Color(1, 1, 1, 1));
                EditorHelp.DrawSecDef(new Rect(aex + 4 - 4, ady + 4, 9, 9), "mini");
                bool res = (i % 2 == 0);

                str = (int)((ae.time / ani_clip.length) * max_frame) + "F";
                float exlx = ((aex + 8 + str.Length * 8 > position.width)?position.width - str.Length * 8 - 4:aex + 4);
                GUI.Label(new Rect(exlx, ady - 14, exw, 14), str, EditorStyles.miniLabel);

                str  = ae.time.ToString("f2") + "s";
                exlx = ((aex + 8 + str.Length * 6 > position.width)?position.width - str.Length * 6 - 4:aex + 4);
                GUI.Label(new Rect(exlx, res?ady + 14:ady + 24, exw, 14), str, EditorStyles.miniLabel);
            }



            ady += 2;
            //GUI.Label
            GUI.color = new Color(1, 1, 1, 0.35f);
            adx       = 2;
            GUI.Box(new Rect(adx, ady, position.width - 2 - adx, position.height - 2 - ady), "", EditorStyles.miniButton);
            ady      += 38;
            GUI.color = Color.white;
            //	GUI.Label(new Rect(adx,ady,200,20),"isAnimatorMotion:"+ani_clip.isAnimatorMotion);ady+=20;
            //		GUI.Label(new Rect(adx,ady,200,20),"isHumanMotion:"+ani_clip.isHumanMotion);ady+=20;

            //	GUI.Label(new Rect(adx,ady,200,20),"localBounds:"+ani_clip.localBounds);ady+=20;

            if (Event.current.isKey && Event.current.keyCode == KeyCode.Return)
            {
                //Debug.Log("xx");
                Repaint();
            }

            for (int i = 0; i < ani_events.Count; i++)
            {
                AnimationEvent ae = ani_events[i];
                str = ae.stringParameter;
                int size = str.Split('\n').Length;
                size = size * 13 + 4;
                bool res = (ae.functionName != "_start" && ae.functionName != "_end");


                GUI.color = new Color(1, 1, 1, res?0.5f:0.6f);
                GUI.Label(new Rect(adx, ady + (res?0:2), (res?position.width - 4 - adx:60), (res?24 + size:20)), "", EditorStyles.miniButton);
                GUI.color = Color.white;

                if (!res)
                {
                    bool res2 = (ae.functionName == "_start");
                    GUI.color = res2?new Color(0.3f, 1f, 0.3f, 1):new Color(0.2f, 0.8f, 1, 1);

                    GUI.Label(new Rect(adx, ady + 4, 60, 20), " " + (res2?"Start":"End"));            //ady+=20;
                    GUI.color = Color.white;
                    //ady+=2;
                }
                else
                {
                    GUI.Label(new Rect(adx, ady, 200, 20), ae.functionName);

                    GUI.Label(new Rect(position.width - 44, ady, 40, 20), (ae.time / ani_clip.length) * max_frame + "F"); ady += 20; adx = 4;
                    //GUI.Label(new Rect(adx,ady,200,20),"事件参数:"+ae.stringParameter);ady+=20;
                    int pre_id = str.IndexOf("[int]");
                    if (pre_id != -1)
                    {
                        str.Remove(pre_id, 4);
                        //str.Insert(pre_id,"xxxw");
                    }

                    string nxe = GUI.TextArea(new Rect(adx + 2, ady, position.width - 10 - adx, size), str, EditorStyles.numberField);

                    if (nxe != str)
                    {
                        ae.stringParameter = nxe;
                        SaveAniEventList();
                    }
                }



                ady += size + 6;
            }

            //	GUI.Label(new Rect(adx,ady,200,20),"localBounds:"+ani_clip.localBounds);ady+=20;
        }



        /*
         * EventType eventType=  Event.current.type;
         * if (eventType == EventType.DragUpdated || eventType == EventType.DragPerform)
         * {
         *      // Show a copy icon on the drag
         *      //拖动时显示辅助图标
         *      DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
         *
         *      if (eventType == EventType.DragPerform)
         *      {
         *              DragAndDrop.AcceptDrag();
         *
         *              if(DragAndDrop.objectReferences .Length>0)
         *              {
         *                      if(DragAndDrop.paths.Length>0)
         *                      {
         *                              string[] fn=DragAndDrop.paths;
         *                              List<string> strs=new List<string>() ;
         *
         *                              for(int i=0;i<fn.Length;i++)
         *                              {
         *                                      string str=fn[i];
         *                                      if(str.Contains(".png"))
         *                                      {
         *                                              strs.Add(fn[i]);
         *                                      }
         *                              }
         *                              AnimationClip ac=DragAndDrop.objectReferences[0] as AnimationClip;
         *                              LoadAnimation(ac);
         *                              if(strs.Count>0)
         *                              {
         *
         *
         *                                      string path=strs[0];
         *                                      int pos=path.LastIndexOf('/');
         *                                      path=	path.Remove(pos,path.Length-pos);
         *                                      fn=new string[strs.Count];
         *                                      for(int i=0;i<strs.Count;i++)
         *                                      {
         *                                              fn[i]=strs[i];
         *                                      }
         *
         *                                      //Debug.Log(path);
         *
         *                                      //TexLoad(fn,path);
         *                              }
         *
         *                      }
         *              }
         *              else
         *              {
         *                      if(DragAndDrop.paths.Length>0)
         *                      {
         *                              string path=DragAndDrop.paths[0];
         *                              //StartLoad(path);
         *                      }
         *              }
         *
         *              DragAndDrop.PrepareStartDrag ();
         *      }
         *
         *
         *      Event.current.Use();
         * }
         */
    }
    public static void ShowTab(CharacterControllerBase a_CharacterController)
    {
        if (a_CharacterController == null)
        {
            GUILayout.Label("CharacterController script not found on object", EditorStyles.boldLabel);
            return;
        }

        GroundedCharacterController groundedChar = (GroundedCharacterController)a_CharacterController;
        ControlledCapsuleCollider   capsuleCol   = (ControlledCapsuleCollider)a_CharacterController.GetCollider();

        if (groundedChar && capsuleCol)
        {
            SerializedObject charObject = new SerializedObject(groundedChar);
            SerializedObject colObject  = new SerializedObject(capsuleCol);
            EditorGUI.BeginChangeCheck();

            float prevLabelWidth = EditorGUIUtility.labelWidth;
            EditorGUIUtility.labelWidth += 50.0f;

            GUILayout.Label("Variables for movement", EditorStyles.boldLabel);
            GUILayout.Space(4.0f);

            if (EditorHelp.Foldout("Basic character settings"))
            {
                EditorGUI.indentLevel++;
                EditorHelp.SerializeRelativeField(colObject, "m_LayerMask", "", "Collision mask");
                EditorHelp.SerializeRelativeField(colObject, "m_Length", "The length of the capsule (not including both demispheres)", "Capsule length");
                EditorHelp.SerializeRelativeField(colObject, "m_Radius", "The radius of the capsule", "Capsule radius");
                EditorHelp.SerializeRelativeField(charObject, "m_Gravity", "How fast a character falls downwards");
                EditorHelp.SerializeRelativeField(charObject, "m_DragConstant", "A force that slows down the character (low values work best!)", "Drag");
                GUILayout.Space(4.0f);
                EditorGUI.indentLevel--;
            }

            if (EditorHelp.Foldout("Running"))
            {
                EditorGUI.indentLevel++;
                EditorHelp.SerializeRelativeField(charObject, "m_WalkForce", "How fast a character can accelerate", "Character acceleration");
                EditorHelp.SerializeRelativeField(charObject, "m_WalkForceApplyLimit", "The maximum speed a character can accelerate to by running", "Max running speed");
                EditorHelp.SerializeRelativeField(charObject, "m_StoppingForce", "How fast a character can stop running when the player releases run input", "Brake deceleration");
                EditorHelp.SerializeRelativeField(charObject, "m_ApplyStoppingForceWhenActivelyBraking", "Whether the character uses Brake deceleration when the player turns around mid-run (prevents sliding)", "Brake when changing direction");
                EditorHelp.SerializeRelativeField(charObject, "m_FrictionConstant", "Slows down the character when its on the ground", "Friction");
                GUILayout.Space(4.0f);
                EditorGUI.indentLevel--;
            }

            if (EditorHelp.Foldout("Jumping"))
            {
                EditorGUI.indentLevel++;
                EditorHelp.SerializeRelativeField(charObject, "m_JumpVelocity", "The velocity that is applied to the character on jump", "Jump velocity");
                EditorHelp.SerializeRelativeField(charObject, "m_JumpCutVelocity", "The vertical velocity that the character will use when the jump button is let go after jumping (this leads to different jump heights)", "Low jump velocity");
                EditorHelp.SerializeRelativeField(charObject, "m_MinAllowedJumpCutVelocity", "If the jump button is let go after jumping, and its vertical velocity is below this threshold, the character will switch to Low jump velocity (value above this one) ", "Velocity threshold for low jump");
                EditorHelp.SerializeRelativeField(charObject, "m_HorizontalJumpBoostFactor", "How much of the horizontal velocity should be added to the character's velocity when jumping", "Horizontal jump boost factor", "range01");
                EditorHelp.SerializeRelativeField(charObject, "m_JumpAlignedToGroundFactor", "How much the jump direction should be influenced by the ground (0 is jumping straight up, 1 is jumping away from the ground)", "Jump aligned to ground factor", "range01");
                EditorHelp.SerializeRelativeField(charObject, "m_GroundedToleranceTime", "The time (in seconds) after not being grounded where a jump press is still valid. If a player presses jump just after falling off a platform, the character will still jump. ", "Jump grounded tolerance time");
                EditorHelp.SerializeRelativeField(charObject, "m_JumpCacheTime", "The time (in seconds) after which a jump press is still valid. If a player presses jump before standing on the ground, but lands within this amount of seconds, the character will still jump", "Jump input valid time");
                EditorHelp.SerializeRelativeField(charObject, "m_ResetVerticalSpeedOnJumpIfMovingDown", "If the character is running downhill and the player presses jump, should the downwards velocity be reset before jumping? Could otherwise lead to low jumps in this situation", "Reset down velocity on jump");
                GUILayout.Space(4.0f);
                EditorGUI.indentLevel--;
            }
            if (EditorHelp.Foldout("Air control"))
            {
                EditorGUI.indentLevel++;
                EditorHelp.SerializeRelativeField(charObject, "m_AirControl", "How fast a character can accelerate in the air (as a factor of its regular acceleration). 0 is no acceleration, 1 is just as fast as on the ground", "In-air character acceleration", "range01");
                EditorHelp.SerializeRelativeField(charObject, "m_AirForceApplyLimit", "The maximum speed a character can accelerate to by moving in the air. ", "Max horizontal in-air speed");
                GUILayout.Space(4.0f);
                EditorGUI.indentLevel--;
            }
            if (EditorHelp.Foldout("Environmental context"))
            {
                EditorGUI.indentLevel++;
                EditorHelp.SerializeRelativeField(colObject, "m_MaximumGroundedAngle", "The maximum angle a character can still walk on(from straight up)", "Max ground angle");
                EditorHelp.SerializeRelativeField(colObject, "m_MaximumWallAngle", "The maximum angle a character can still align to a wall with(from straight up)", "Max wall angle");
                EditorHelp.SerializeRelativeField(colObject, "m_MaxGrabAngle", "The maximum angle of the surface on a ledge where a character can still grab on to (from straight up)", "Max edge ground angle");
                EditorHelp.SerializeRelativeField(colObject, "m_MaxEdgeAlignAngle", "The maximum angle of the wall before a ledge where a character can still align to (from straight up)", "Max edge wall angle");
                GUILayout.Space(4.0f);
                EditorGUI.indentLevel--;
            }
            if (EditorHelp.Foldout("Various"))
            {
                EditorGUI.indentLevel++;
                EditorHelp.SerializeRelativeField(charObject, "m_ApplyGravityOnGround", "Should the character apply gravity when it's standing on the ground?", "Gravity active on ground");
                if (charObject.FindProperty("m_ApplyGravityOnGround").boolValue)
                {
                    EditorHelp.SerializeRelativeField(charObject, "m_ApplyGravityIntoGroundNormal", "Should the gravity on the ground be pointed in the direction of the ground (when checked), or should it point straight down (when unchecked)? If unchecked, gravity will pull the character downhill", "Gravity directed into ground");
                }
                GUILayout.Space(4.0f);
                EditorGUI.indentLevel--;
            }

            EditorGUIUtility.labelWidth = prevLabelWidth;

            if (EditorGUI.EndChangeCheck())
            {
                charObject.ApplyModifiedProperties();
                colObject.ApplyModifiedProperties();
            }
        }
        else
        {
            if (!groundedChar)
            {
                GUILayout.Label("This is not a grounded character controller", EditorStyles.boldLabel);
            }
            if (!capsuleCol)
            {
                GUILayout.Label("This character does not have a controlled capsule collider script", EditorStyles.boldLabel);
            }
        }
    }
Beispiel #17
0
 static void DoIt()
 {
     //EditorUtility.DisplayDialog("MyTool", "Do It in C# !", "OK", "");
     help = GetWindow <EditorHelp>();
 }
Beispiel #18
0
 /// <summary>
 /// 保存动画事件列表
 /// </summary>
 void SaveAniEventList()
 {
     AnimationUtility.SetAnimationEvents(ani_clip, EditorHelp.CopyAnimaEventListToArray(ani_events));
     EditorUtility.SetDirty(ani_clip);
 }
Beispiel #19
0
 public void OnEnable()
 {
     editorHelp = new EditorHelp();
 }