Example #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();
        }
Example #2
0
        protected virtual void OnGUI()
        {
            if (hideWhileSight)
            {
                showCrosshair = !UInput.GetButton(INC.SIGHT);
            }

            if (showCrosshair && verticalTexture && horizontalTexture)
            {
                GUI.color = crosshairColor;
                switch (preset)
                {
                case Preset.Default:
                    GUIUtility.RotateAroundPivot(angle, center);
                    GUI.DrawTexture(new Rect((Screen.width - width) / 2, (Screen.height - spread) / 2 - height, width, height), horizontalTexture);
                    GUI.DrawTexture(new Rect((Screen.width - width) / 2, (Screen.height + spread) / 2, width, height), horizontalTexture);
                    GUI.DrawTexture(new Rect((Screen.width - spread) / 2 - height, (Screen.height - width) / 2, height, width), verticalTexture);
                    GUI.DrawTexture(new Rect((Screen.width + spread) / 2, (Screen.height - width) / 2, height, width), verticalTexture);
                    break;

                case Preset.Shotgun:
                    GUIUtility.RotateAroundPivot(angle, center);
                    GUI.DrawTexture(new Rect((Screen.width - height) / 2, (Screen.height - spread) / 2 - width, height, width), horizontalTexture);
                    GUI.DrawTexture(new Rect((Screen.width - height) / 2, (Screen.height + spread) / 2, height, width), horizontalTexture);
                    GUI.DrawTexture(new Rect((Screen.width - spread) / 2 - width, (Screen.height - height) / 2, width, height), verticalTexture);
                    GUI.DrawTexture(new Rect((Screen.width + spread) / 2, (Screen.height - height) / 2, width, height), verticalTexture);
                    break;

                case Preset.Triangle:
                    GUIUtility.RotateAroundPivot(angle, center);
                    GUI.DrawTexture(new Rect((Screen.width - 2) / 2, (Screen.height - spread) / 2 - 14, width, height), horizontalTexture);
                    GUIUtility.RotateAroundPivot(45, center);
                    GUI.DrawTexture(new Rect((Screen.width + spread) / 2, (Screen.height - 2) / 2, height, width), horizontalTexture);
                    GUIUtility.RotateAroundPivot(0, center);
                    GUI.DrawTexture(new Rect((Screen.width - 2) / 2, (Screen.height + spread) / 2, width, height), horizontalTexture);
                    break;
                }
                GUI.color = Color.white;
            }

            if (hitEffectIsActive && hitEffectTexture)
            {
                if (!UMathf.Approximately(hitEffectColor.a, 0, 0.001f))
                {
                    hitEffectColor.a = Mathf.SmoothStep(hitEffectColor.a, 0, hitEffectHideSpeed * Time.deltaTime);
                }
                GUI.color = hitEffectColor;
                GUIUtility.RotateAroundPivot(hitEffecntAngle, center);
                GUI.DrawTexture(new Rect((Screen.width - hitEffectWidth) / 2, (Screen.height - hitEffectSpread) / 2 - hitEffectHeight, hitEffectWidth, hitEffectHeight), hitEffectTexture);
                GUI.DrawTexture(new Rect((Screen.width - hitEffectWidth) / 2, (Screen.height + hitEffectSpread) / 2, hitEffectWidth, hitEffectHeight), hitEffectTexture);
                GUI.DrawTexture(new Rect((Screen.width - hitEffectSpread) / 2 - hitEffectHeight, (Screen.height - hitEffectWidth) / 2, hitEffectHeight, hitEffectWidth), hitEffectTexture);
                GUI.DrawTexture(new Rect((Screen.width + hitEffectSpread) / 2, (Screen.height - hitEffectWidth) / 2, hitEffectHeight, hitEffectWidth), hitEffectTexture);
            }
        }
Example #3
0
 public virtual IEnumerator SetSpread(float spread, float smooth)
 {
     while (true)
     {
         this.spread = Mathf.SmoothStep(this.spread, spread, smooth);
         if (UMathf.Approximately(this.spread, spread, 0.01f))
         {
             yield break;
         }
         yield return(null);
     }
 }
        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>());
            }
        }