示例#1
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            PlayerController playerController = (PlayerController)target;

            GUILayout.Label("Forward Speeds", "BoldLabel");
            DistanceValueList forwardSpeedList = playerController.forwardSpeeds;

            if (DistanceValueListInspector.ShowLoopToggle(ref forwardSpeedList, DistanceValueType.Speed))
            {
                playerController.forwardSpeeds = forwardSpeedList;
                EditorUtility.SetDirty(target);
            }
            DistanceValueListInspector.ShowDistanceValues(ref forwardSpeedList, DistanceValueType.Speed);

            if (DistanceValueListInspector.ShowAddNewValue(ref forwardSpeedList, DistanceValueType.Speed))
            {
                playerController.forwardSpeeds = forwardSpeedList;
                EditorUtility.SetDirty(target);
            }
        }
        public void OnGUI()
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);

            GUILayout.Label("This wizard will assist in the creation of a new character.\nThe more frequently changed fields are listed and the\nunlisted fields will remain with their default value.\n" +
                            "All of these values can be changed at a later point in time.");
            GUILayout.Space(5);
            GUILayout.Label("Model", "BoldLabel");
            if (model == null)
            {
                GUI.color = Color.red;
            }
            model     = EditorGUILayout.ObjectField("Character Model", model, typeof(GameObject), true) as GameObject;
            GUI.color = Color.white;

            GUILayout.Label("Player", "BoldLabel");
            horizontalSpeed = EditorGUILayout.FloatField("Horizontal Speed", horizontalSpeed);
            jumpHeight      = EditorGUILayout.FloatField("Jump Height", jumpHeight);
            slideDuration   = EditorGUILayout.FloatField("Slide Duration", slideDuration);
            attackType      = (AttackType)EditorGUILayout.EnumPopup("Attack Type", attackType);
            if (attackType == AttackType.Fixed)
            {
                attackCloseDistance = EditorGUILayout.FloatField("Close Attack Distance", attackCloseDistance);
                attackFarDistance   = EditorGUILayout.FloatField("Far Attack Distance", attackFarDistance);
            }
            else if (attackType == AttackType.Projectile)
            {
                projectileObject = EditorGUILayout.ObjectField("Projectile", projectileObject, typeof(ProjectileObject), true) as ProjectileObject;
            }
            autoTurn = EditorGUILayout.Toggle("Auto Turn?", autoTurn);
            autoJump = EditorGUILayout.Toggle("Auto Jump?", autoJump);

            DistanceValueListInspector.ShowLoopToggle(ref forwardSpeedList, DistanceValueType.Speed);
            if (forwardSpeedList == null || forwardSpeedList.Count() == 0)
            {
                GUI.color = Color.red;
            }
            DistanceValueListInspector.ShowDistanceValues(ref forwardSpeedList, DistanceValueType.Speed);
            GUI.color = Color.white;
            DistanceValueListInspector.ShowAddNewValue(ref forwardSpeedList, DistanceValueType.Speed);

            GUILayout.Space(5);
            GUILayout.Label("Particles", "BoldLabel");
            GUILayout.Label("Optionally specify a character to copy the particles from");
            particleSource = EditorGUILayout.ObjectField("Particles Source", particleSource, typeof(PlayerController), true) as PlayerController;

            GUILayout.Space(5);
            GUILayout.Label("Animations", "BoldLabel");
            useMecanim = EditorGUILayout.Toggle("Use Mecanim?", useMecanim);
            if (useMecanim)
            {
                runStateName           = EditorGUILayout.TextField("Run State Name", runStateName);
                jumpStateName          = EditorGUILayout.TextField("Jump State Name", jumpStateName);
                slideStateName         = EditorGUILayout.TextField("Slide State Name", slideStateName);
                rightStrafeStateName   = EditorGUILayout.TextField("Right Strafe State Name", rightStrafeStateName);
                leftStrafeStateName    = EditorGUILayout.TextField("Left Strafe State Name", leftStrafeStateName);
                attackStateName        = EditorGUILayout.TextField("Attack State Name", attackStateName);
                backwardDeathStateName = EditorGUILayout.TextField("Backward Death State Name", backwardDeathStateName);
                forwardDeathStateName  = EditorGUILayout.TextField("Forward Death State Name", forwardDeathStateName);
                idleStateName          = EditorGUILayout.TextField("Idle State Name", idleStateName);
            }
            else
            {
                runAnimationName            = EditorGUILayout.TextField("Run Animation Name", runAnimationName);
                runJumpAnimationName        = EditorGUILayout.TextField("Jump Animation Name", runJumpAnimationName);
                runSlideAnimationName       = EditorGUILayout.TextField("Slide Animation Name", runSlideAnimationName);
                runRightStrafeAnimationName = EditorGUILayout.TextField("Right Strafe Animation Name", runRightStrafeAnimationName);
                runLeftStrafeAnimationName  = EditorGUILayout.TextField("Left Strafe Animation Name", runLeftStrafeAnimationName);
                attackAnimationName         = EditorGUILayout.TextField("Attack Animation Name", attackAnimationName);
                backwardDeathAnimationName  = EditorGUILayout.TextField("Backward Death Animation Name", backwardDeathAnimationName);
                forwardDeathAnimationName   = EditorGUILayout.TextField("Forward Death Animation Name", forwardDeathAnimationName);
                idleAnimationName           = EditorGUILayout.TextField("Idle Animation Name", idleAnimationName);
            }

            if (model == null || forwardSpeedList == null || forwardSpeedList.Count() == 0)
            {
                GUI.enabled = false;
            }
            GUILayout.Space(10);
            if (GUILayout.Button("Create") && GUI.enabled)
            {
                CreateCharacter();
            }
            GUI.enabled = true;

            GUILayout.EndScrollView();
        }