Пример #1
0
        public override void InitializeProperties()
        {
            Transform player = UEditorInternal.FindPlayer();

            if (player != null)
            {
                inventory = UEditorInternal.FindComponent <AdvancedInventory>(player);
            }
        }
        /// <summary>
        /// This function is called when the window becomes enabled and active.
        /// </summary>
        public static void OnEnable()
        {
            properties   = new WeaponProperties();
            delay        = new EditorDelay(0.1f);
            toolbarItems = new string[] { "First Person Weapon", "Pickable Weapon" };
            Transform player = UEditorInternal.FindPlayer();

            if (player != null)
            {
                inventory = UEditorInternal.FindComponent <AdvancedInventory>(player);
            }
            additionalComponents = new List <AdditionalComponents>()
            {
                new AdditionalComponents
                {
                    name      = "Crosshair",
                    component = typeof(Crosshair),
                    isActive  = true
                },
                new AdditionalComponents
                {
                    name      = "Camera Zoom",
                    component = typeof(FPCameraZoom),
                    isActive  = true
                }
            };
            additionalComponentsRL = new ReorderableList(additionalComponents, typeof(AdditionalComponents), true, true, false, false)
            {
                drawHeaderCallback = (rect) =>
                {
                    EditorGUI.LabelField(new Rect(rect.x, rect.y + 1, 200, EditorGUIUtility.singleLineHeight), "Additional Components");
                },

                drawElementCallback = (rect, index, isActive, isFocused) =>
                {
                    AdditionalComponents additionalSystem = additionalComponents[index];
                    EditorGUI.LabelField(new Rect(rect.x, rect.y + 2, 100, EditorGUIUtility.singleLineHeight), additionalSystem.name);
                    additionalSystem.isActive   = EditorGUI.Toggle(new Rect(rect.width + 10, rect.y + 2, 30, EditorGUIUtility.singleLineHeight), additionalSystem.isActive);
                    additionalComponents[index] = additionalSystem;
                }
            };
        }
Пример #3
0
        public static void OnEnable()
        {
            weaponID = ScriptableObject.CreateInstance <WeaponID>();
            if (weaponID != null)
            {
                weaponID.SetID(WeaponID.GenerateID());
                weaponID.SetDisplayName("Write weapon name here...");
            }
            Transform player = UEditorInternal.FindPlayer();

            if (player != null)
            {
                inventory = UEditorInternal.FindComponent <AdvancedInventory>(player);
            }

            weaponIDs    = UEditorInternal.FindAssetsByType <WeaponID>();
            toolbarItems = new string[2] {
                "New", "List"
            };
        }
        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>());
            }
        }