示例#1
0
        public override void BaseGUI()
        {
            BeginBox();
            GUILayout.Label(ContentProperties.AmmoProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(5);
            instance.SetBulletCount(EditorGUILayout.IntSlider(ContentProperties.BulletCount, instance.GetBulletCount(), 0, instance.GetMaxBulletCount()));
            instance.SetMaxBulletCount(EditorGUILayout.IntField(ContentProperties.MaxBulletCount, instance.GetMaxBulletCount()));

            GUILayout.Space(10);
            GUILayout.Label(ContentProperties.ReloadingProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            if (clips != null && clips.Length > 0)
            {
                GUILayout.BeginHorizontal();
                instance.SetReloadTime(EditorGUILayout.FloatField(ContentProperties.ReloadTime, instance.GetReloadTime()));
                if (ListButton())
                {
                    GenericMenu menu = new GenericMenu();
                    for (int i = 0, length = clips.Length; i < length; i++)
                    {
                        AnimationClip clip = clips[i];
                        menu.AddItem(new GUIContent(clip.name), UMathf.Approximately(clip.length, instance.GetReloadTime(), 0.01f), (x) => { instance.SetReloadTime(UMathf.AllocatePart((float)x)); }, clip.length);
                    }
                    menu.ShowAsContext();
                }
                GUILayout.EndHorizontal();
            }
            else
            {
                instance.SetReloadTime(EditorGUILayout.FloatField(ContentProperties.ReloadTime, instance.GetReloadTime()));
            }
            instance.SetReloadSound((AudioClip)EditorGUILayout.ObjectField(ContentProperties.ReloadSound, instance.GetReloadSound(), typeof(AudioClip), true));
            EndBox();
        }
        public override void BaseGUI()
        {
            BeginBox();
            GUILayout.BeginVertical();
            GUILayout.Label(ContentProperties.AmmoProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(5);
            instance.SetBulletCount(EditorGUILayout.IntSlider(ContentProperties.BulletCount, instance.GetBulletCount(), 0, instance.GetMaxBulletCount()));
            instance.SetClipCount(EditorGUILayout.IntSlider(ContentProperties.ClipCount, instance.GetClipCount(), 0, instance.GetMaxClipCount()));
            instance.SetMaxBulletCount(EditorGUILayout.IntField(ContentProperties.MaxBulletCount, instance.GetMaxBulletCount()));
            instance.SetMaxClipCount(EditorGUILayout.IntField(ContentProperties.MaxClipCount, instance.GetMaxClipCount()));

            GUILayout.Space(10);
            GUILayout.Label(ContentProperties.ReloadProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            instance.SetReloadType((WeaponReloadSystem.ReloadType)EditorGUILayout.EnumPopup(ContentProperties.ReloadType, instance.GetReloadType()));
            instance.SetReloadMode((WeaponReloadSystem.ReloadMode)EditorGUILayout.EnumPopup(ContentProperties.ReloadMode, instance.GetReloadMode()));
            switch (instance.GetReloadMode())
            {
            case WeaponReloadSystem.ReloadMode.Default:
                if (clips != null && clips.Length > 0)
                {
                    GUILayout.BeginHorizontal();
                    instance.SetReloadTime(EditorGUILayout.FloatField(ContentProperties.ReloadTime, instance.GetReloadTime()));
                    if (ListButton())
                    {
                        GenericMenu menu = new GenericMenu();
                        for (int i = 0, length = clips.Length; i < length; i++)
                        {
                            AnimationClip clip = clips[i];
                            menu.AddItem(new GUIContent(clip.name), UMathf.Approximately(clip.length, instance.GetReloadTime(), 0.01f), (x) => { instance.SetReloadTime(UMathf.AllocatePart((float)x)); }, clip.length);
                        }
                        menu.ShowAsContext();
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    instance.SetEmptyReloadTime(EditorGUILayout.FloatField(ContentProperties.EmptyReloadTime, instance.GetEmptyReloadTime()));
                    if (ListButton())
                    {
                        GenericMenu menu = new GenericMenu();
                        for (int i = 0, length = clips.Length; i < length; i++)
                        {
                            AnimationClip clip = clips[i];
                            menu.AddItem(new GUIContent(clip.name), UMathf.Approximately(clip.length, instance.GetEmptyReloadTime(), 0.01f), (x) => { instance.SetEmptyReloadTime(UMathf.AllocatePart((float)x)); }, clip.length);
                        }
                        menu.ShowAsContext();
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    instance.SetReloadTime(EditorGUILayout.FloatField(ContentProperties.ReloadTime, instance.GetReloadTime()));
                    instance.SetEmptyReloadTime(EditorGUILayout.FloatField(ContentProperties.EmptyReloadTime, instance.GetEmptyReloadTime()));
                }
                break;

            case WeaponReloadSystem.ReloadMode.Sequential:
                if (clips != null && clips.Length > 0)
                {
                    GUILayout.BeginHorizontal();
                    instance.SetStartTime(EditorGUILayout.FloatField(ContentProperties.StartTime, instance.GetStartTime()));
                    if (ListButton())
                    {
                        GenericMenu menu = new GenericMenu();
                        for (int i = 0, length = clips.Length; i < length; i++)
                        {
                            AnimationClip clip = clips[i];
                            menu.AddItem(new GUIContent(clip.name), UMathf.Approximately(clip.length, instance.GetStartTime(), 0.01f), (x) => { instance.SetStartTime(UMathf.AllocatePart((float)x)); }, clip.length);
                        }
                        menu.ShowAsContext();
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    instance.SetIterationTime(EditorGUILayout.FloatField(ContentProperties.IterationTime, instance.GetIterationTime()));
                    if (ListButton())
                    {
                        GenericMenu menu = new GenericMenu();
                        for (int i = 0, length = clips.Length; i < length; i++)
                        {
                            AnimationClip clip = clips[i];
                            menu.AddItem(new GUIContent(clip.name), UMathf.Approximately(clip.length, instance.GetIterationTime(), 0.01f), (x) => { instance.SetIterationTime(UMathf.AllocatePart((float)x)); }, clip.length);
                        }
                        menu.ShowAsContext();
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    instance.SetStartTime(EditorGUILayout.FloatField(ContentProperties.StartTime, instance.GetStartTime()));
                    instance.SetIterationTime(EditorGUILayout.FloatField(ContentProperties.IterationTime, instance.GetIterationTime()));
                }
                break;

            default:
                UEditorHelpBoxMessages.Message("Select some one ReloadType...", MessageType.Warning, true);
                break;
            }
            GUILayout.EndVertical();
            EndBox();

            if (GUI.changed)
            {
                clips = UEditorInternal.GetAllClips(instance.GetComponent <Animator>());
            }
        }
        public override void BaseGUI()
        {
            BeginBox();
            GUILayout.Label(ContentProperties.MainProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            instance.SetPlayer((Transform)EditorGUILayout.ObjectField(ContentProperties.Player, instance.GetPlayer(), typeof(Transform), true));
            if (instance.GetPlayer() == null)
            {
                if (MiniButton("Try find Camera"))
                {
                    Transform player = UEditorInternal.FindPlayer();
                    if (player != null)
                    {
                        instance.SetPlayer(player);
                    }
                    else
                    {
                        UDisplayDialogs.Message("Searching", "Player not found, try find it manually.");
                    }
                }
                UEditorHelpBoxMessages.PlayerError();
            }
            instance.SetOriginalYAxis(EditorGUILayout.Slider(ContentProperties.OriginalYAxis, instance.GetOriginalYAxis(), -360.0f, 360.0f));
            instance.SetAnimationEventProperties(ObjectField <AnimationEventProperties>(ContentProperties.EventProperties, instance.GetAnimationEventProperties(), true));

            GUILayout.Space(10);
            GUILayout.Label("Animator", UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(5);

            if (clips != null && clips.Length > 0)
            {
                GUILayout.BeginHorizontal();
                instance.SetTakeTime(EditorGUILayout.FloatField(ContentProperties.TakeTime, instance.GetTakeTime()));
                if (ListButton())
                {
                    GenericMenu menu = new GenericMenu();
                    for (int i = 0, length = clips.Length; i < length; i++)
                    {
                        AnimationClip clip = clips[i];
                        menu.AddItem(new GUIContent(clip.name), UMathf.Approximately(clip.length, instance.GetTakeTime(), 0.01f), (x) => { instance.SetTakeTime(UMathf.AllocatePart((float)x)); }, clip.length);
                    }
                    menu.ShowAsContext();
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                instance.SetPutAwayTime(EditorGUILayout.FloatField(ContentProperties.PutAwayTime, instance.GetPutAwayTime()));
                if (ListButton())
                {
                    GenericMenu menu = new GenericMenu();
                    for (int i = 0, length = clips.Length; i < length; i++)
                    {
                        AnimationClip clip = clips[i];
                        menu.AddItem(new GUIContent(clip.name), UMathf.Approximately(clip.length, instance.GetPutAwayTime(), 0.01f), (x) => { instance.SetPutAwayTime(UMathf.AllocatePart((float)x)); }, clip.length);
                    }
                    menu.ShowAsContext();
                }
                GUILayout.EndHorizontal();
            }
            else
            {
                instance.SetTakeTime(EditorGUILayout.FloatField(ContentProperties.TakeTime, instance.GetTakeTime()));
                instance.SetPutAwayTime(EditorGUILayout.FloatField(ContentProperties.PutAwayTime, instance.GetPutAwayTime()));
            }

            GUILayout.Space(10);
            GUILayout.Label("Vector Animations", UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(5);
            BeginSubBox();
            EditorGUI.BeginDisabledGroup(!instance.UseRotationSway());
            IncreaseIndentLevel();
            rotationSwayFoldout = EditorGUILayout.Foldout(rotationSwayFoldout, ContentProperties.RotationSway, true);
            if (rotationSwayFoldout)
            {
                instance.SetPositionSensitivity(EditorGUILayout.FloatField(ContentProperties.PositionSensitivity, instance.GetPositionSensitivity()));
                instance.SetMaxPositionSensitivity(EditorGUILayout.FloatField(ContentProperties.MaxPositionSensitivity, instance.GetMaxPositionSensitivity()));
                instance.SetSmoothPosition(EditorGUILayout.FloatField(ContentProperties.SmoothPosition, instance.GetSmoothPosition()));
                instance.SetSmoothRotation(EditorGUILayout.FloatField(ContentProperties.SmoothRotation, instance.GetSmoothRotation()));
                instance.SetRotationSensitivity(EditorGUILayout.FloatField(ContentProperties.RotationSensitivity, instance.GetRotationSensitivity()));
            }
            string rotationSwayToggleName = instance.UseRotationSway() ? "Rotation Sway Enabled" : "Rotation Sway Disabled";

            EditorGUI.EndDisabledGroup();
            if (rotationSwayFoldout && !instance.UseRotationSway())
            {
                Rect notificationBackgroungRect = GUILayoutUtility.GetLastRect();
                Rect notificationTextRect       = GUILayoutUtility.GetLastRect();

                notificationBackgroungRect.y     -= 75;
                notificationBackgroungRect.height = 93.5f;

                notificationTextRect.y     -= 58.5f;
                notificationTextRect.height = 60;

                Notification("Rotation Sway Disabled", notificationBackgroungRect, notificationTextRect);
            }
            instance.RotationSwayActive(EditorGUILayout.Toggle(rotationSwayToggleName, instance.UseRotationSway()));
            EndSubBox();

            BeginSubBox();
            EditorGUI.BeginDisabledGroup(!instance.UseJumpSway());
            jumpSwayFoldout = EditorGUILayout.Foldout(jumpSwayFoldout, ContentProperties.JumpSway, true);
            if (jumpSwayFoldout)
            {
                instance.SetMaxYPosJump(EditorGUILayout.FloatField(ContentProperties.MaxYPosJump, instance.GetMaxYPosJump()));
                instance.SetSmoothJump(EditorGUILayout.FloatField(ContentProperties.SmoothJump, instance.GetSmoothJump()));
                instance.SetSmoothLand(EditorGUILayout.FloatField(ContentProperties.SmoothLand, instance.GetSmoothLand()));
            }
            string jumpSwayToggleName = instance.UseJumpSway() ? "Jump Sway Enabled" : "Jump Sway Disabled";

            EditorGUI.EndDisabledGroup();
            if (jumpSwayFoldout && !instance.UseJumpSway())
            {
                Rect notificationBackgroungRect = GUILayoutUtility.GetLastRect();
                Rect notificationTextRect       = GUILayoutUtility.GetLastRect();

                notificationBackgroungRect.y     -= 39;
                notificationBackgroungRect.height = 58;

                notificationTextRect.y     -= 36.5f;
                notificationTextRect.height = 50;

                Notification("Jump Sway Disabled", notificationBackgroungRect, notificationTextRect);
            }
            instance.JumpSwayActive(EditorGUILayout.Toggle(jumpSwayToggleName, instance.UseJumpSway()));
            EndSubBox();
            DecreaseIndentLevel();
            EndBox();

            if (GUI.changed)
            {
                clips = UEditorInternal.GetAllClips(instance.GetComponent <Animator>());
            }
        }