protected override void OnInspectorGUIUpdate()
    {
        base.OnInspectorGUIUpdate();

        var script = (TransformConstraint)target;

        GUILayout.BeginHorizontal();

        script.constrainPosition = EditorGUILayout.Toggle("Position", script.constrainPosition);

        if (script.constrainPosition)
        {
            GUIStyle style = EditorStyles.toolbarButton;
            style.alignment    = TextAnchor.MiddleCenter;
            style.stretchWidth = true;

            script.outputPosX = GUILayout.Toggle(script.outputPosX, "X", style);
            script.outputPosY = GUILayout.Toggle(script.outputPosY, "Y", style);
            script.outputPosZ = GUILayout.Toggle(script.outputPosZ, "Z", style);
        }
        GUILayout.EndHorizontal();


        GUILayout.BeginHorizontal();
        script.constrainRotation = EditorGUILayout.Toggle("Rotation", script.constrainRotation);
        if (script.constrainRotation)
        {
            script.output = PGEditorUtils.EnumPopup <UnityConstraints.OUTPUT_ROT_OPTIONS>(script.output);
        }
        GUILayout.EndHorizontal();

        script.constrainScale = EditorGUILayout.Toggle("Scale", script.constrainScale);
    }
Beispiel #2
0
    public override void OnInspectorGUI()
    {
        var script = (Targetable)target;

        EditorGUI.indentLevel = 0;
        PGEditorUtils.LookLikeControls();

        script.debugLevel = PGEditorUtils.EnumPopup <DEBUG_LEVELS>("Debug Level", script.debugLevel);

        // Flag Unity to save the changes to to the prefab to disk
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Beispiel #3
0
    protected override void OnInspectorGUIFooter()
    {
        var script = (ConstraintBaseClass)target;

        // For backwards compatibility. I removed an option and it moved these two
        //   Options back, so Once is now Constrain and Constrain is out of bounds.
        //   Unfortunatly I can't fix the old Once back to once.
        if (script._mode != UnityConstraints.MODE_OPTIONS.Align &&
            script._mode != UnityConstraints.MODE_OPTIONS.Constrain)
        {
            script._mode = UnityConstraints.MODE_OPTIONS.Constrain;
        }

        script._mode = PGEditorUtils.EnumPopup <UnityConstraints.MODE_OPTIONS>("Mode", script._mode);

        script._noTargetMode = PGEditorUtils.EnumPopup <UnityConstraints.NO_TARGET_OPTIONS>("No-Target Mode", script._noTargetMode);

        base.OnInspectorGUIFooter();
    }
    protected override void OnInspectorGUIUpdate()
    {
        base.OnInspectorGUIUpdate();

        var script = (SmoothLookAtConstraint)target;

        script.upTarget = PGEditorUtils.ObjectField <Transform>("Up Target (Optional)", script.upTarget);

        script.interpolation = PGEditorUtils.EnumPopup <UnityConstraints.INTERP_OPTIONS>
                               (
            "Interpolation",
            script.interpolation
                               );

        script.speed = EditorGUILayout.FloatField("Speed", script.speed);

        script.output = PGEditorUtils.EnumPopup <UnityConstraints.OUTPUT_ROT_OPTIONS>
                        (
            "Output",
            script.output
                        );
    }
    public override void OnInspectorGUI()
    {
        var script = (TargetTracker)target;

        EditorGUI.indentLevel = 1;
        PGEditorUtils.LookLikeControls();
        script.numberOfTargets = EditorGUILayout.IntField("Targets (-1 for all)", script.numberOfTargets);
        script.targetLayers    = PGEditorUtils.LayerMaskField("Target Layers", script.targetLayers);
        script.sortingStyle    = PGEditorUtils.EnumPopup <TargetTracker.SORTING_STYLES>
                                 (
            "Sorting Style",
            script.sortingStyle
                                 );

        if (script.sortingStyle != TargetTracker.SORTING_STYLES.None)
        {
            EditorGUI.indentLevel = 2;
            script.sortInterval   = EditorGUILayout.FloatField("Minimum Interval", script.sortInterval);
            EditorGUI.indentLevel = 1;
        }

        EditorGUI.indentLevel = 0;
        this.showPerimeter    = EditorGUILayout.Foldout(this.showPerimeter, "Perimeter Settings");

        if (this.showPerimeter)
        {
            EditorGUI.indentLevel = 2;
            script.perimeterLayer = EditorGUILayout.LayerField("Perimeter Layer", script.perimeterLayer);

            EditorGUILayout.BeginHorizontal();

            // Only trigger the update if it actually changes. This runs code in a peroperty
            //   that may be expensive
            var shape = script.perimeterShape;
            shape = PGEditorUtils.EnumPopup <TargetTracker.PERIMETER_SHAPES>("Perimeter Shape", shape);
            if (shape != script.perimeterShape)
            {
                script.perimeterShape = shape;
            }


            GUILayout.Label("Gizmo", GUILayout.MaxWidth(40));
            script.drawGizmo = EditorGUILayout.Toggle(script.drawGizmo, GUILayout.MaxWidth(47));
            EditorGUILayout.EndHorizontal();

            if (script.drawGizmo)
            {
                EditorGUI.indentLevel = 3;
                EditorGUILayout.BeginHorizontal();

                script.gizmoColor = EditorGUILayout.ColorField("Gizmo Color", script.gizmoColor);

                GUIStyle style = EditorStyles.miniButton;
                style.alignment  = TextAnchor.MiddleCenter;
                style.fixedWidth = 52;

                bool clicked = GUILayout.Toggle(false, "Reset", style);
                if (clicked)
                {
                    script.gizmoColor = script.defaultGizmoColor;
                }

                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel = 2;

                GUILayout.Space(4);
            }

            Vector3 range = script.range;
            switch (script.perimeterShape)
            {
            case TargetTracker.PERIMETER_SHAPES.Sphere:
                range.x = EditorGUILayout.FloatField("Range", range.x);
                range.y = range.x;
                range.z = range.x;
                break;

            case TargetTracker.PERIMETER_SHAPES.Box:
                range = EditorGUILayout.Vector3Field("Range", range);
                break;

            case TargetTracker.PERIMETER_SHAPES.Capsule:
                range   = EditorGUILayout.Vector2Field("Range", range);
                range.z = range.x;
                break;
            }
            script.range = range;


            script.perimeterPositionOffset = EditorGUILayout.Vector3Field("Position Offset", script.perimeterPositionOffset);
            script.perimeterRotationOffset = EditorGUILayout.Vector3Field("Rotation Offset", script.perimeterRotationOffset);
        }
        EditorGUI.indentLevel = 1;


        GUILayout.Space(4);
        script.debugLevel = (DEBUG_LEVELS)EditorGUILayout.EnumPopup("Debug Level", (System.Enum)script.debugLevel);


        // Flag Unity to save the changes to to the prefab to disk
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
    public override void OnInspectorGUI()
    {
        var script = (TargetProMessenger)target;

        EditorGUI.indentLevel = 1;
        PGEditorUtils.LookLikeControls();

        script.otherTarget = PGEditorUtils.ObjectField <GameObject>
                             (
            "Other Message Target (Optional)",
            script.otherTarget
                             );

        script.forComponent = (TargetProMessenger.COMPONENTS)EditorGUILayout.EnumPopup
                              (
            new GUIContent("For Component", "Choose which component's events to use"),
            script.forComponent
                              );


        script.messageMode = (TargetProMessenger.MESSAGE_MODE)EditorGUILayout.EnumPopup
                             (
            new GUIContent("Message Mode", "SendMessage will only send to this GameObject"),
            script.messageMode
                             );

        // Change the label spacing
        EditorGUIUtility.LookLikeControls(220);

        EditorGUI.indentLevel = 3;
        if (script.forComponent == TargetProMessenger.COMPONENTS.FireController)
        {
            script.fireController_OnStart        = EditorGUILayout.Toggle("FireController_OnStart", script.fireController_OnStart);
            script.fireController_OnUpdate       = EditorGUILayout.Toggle("FireController_OnUpdate", script.fireController_OnUpdate);
            script.fireController_OnTargetUpdate = EditorGUILayout.Toggle("FireController_OnTargetUpdate", script.fireController_OnTargetUpdate);
            script.fireController_OnIdleUpdate   = EditorGUILayout.Toggle("FireController_OnIdleUpdate", script.fireController_OnIdleUpdate);
            script.fireController_OnFire         = EditorGUILayout.Toggle("FireController_OnFire", script.fireController_OnFire);
            script.fireController_OnStop         = EditorGUILayout.Toggle("FireController_OnStop", script.fireController_OnStop);
        }
        else if (script.forComponent == TargetProMessenger.COMPONENTS.Projectile)
        {
            script.projectile_OnLaunched       = EditorGUILayout.Toggle("Projectile_OnLaunched", script.projectile_OnLaunched);
            script.projectile_OnLaunchedUpdate = EditorGUILayout.Toggle("Projectile_OnLaunchedUpdate", script.projectile_OnLaunchedUpdate);
            script.projectile_OnDetonation     = EditorGUILayout.Toggle("Projectile_OnDetonation", script.projectile_OnDetonation);
        }
        else if (script.forComponent == TargetProMessenger.COMPONENTS.Targetable)
        {
            script.targetable_OnHit         = EditorGUILayout.Toggle("Targetable_OnHit", script.targetable_OnHit);
            script.targetable_OnDetected    = EditorGUILayout.Toggle("Targetable_OnDetected", script.targetable_OnDetected);
            script.targetable_OnNotDetected = EditorGUILayout.Toggle("Targetable_OnNotDetected", script.targetable_OnNotDetected);
        }

        EditorGUI.indentLevel = 1;

        GUILayout.Space(4);

        // Change the label spacing back
        PGEditorUtils.LookLikeControls();
        script.debugLevel = PGEditorUtils.EnumPopup <DEBUG_LEVELS>("Debug Level", script.debugLevel);

        // Flag Unity to save the changes to to the prefab to disk
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Beispiel #7
0
    public bool SerializedObjFoldOutList(string label,
                                         List <CharactersActionData> list,
                                         bool expanded,
                                         ref Dictionary <object, bool> foldOutStates,
                                         bool collapseBools,
                                         Transform tf)
    {
        // Store the previous indent and return the flow to it at the end
        int indent = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;
        int buttonSpacer = 6;

        #region Header Foldout
        // Use a Horizanal space or the toolbar will extend to the left no matter what
        EditorGUILayout.BeginHorizontal();
        EditorGUI.indentLevel = 0;          // Space will handle this for the header
        GUILayout.Space(indent * 6);        // Matches the content indent

        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

        expanded = PGEditorUtils.Foldout(expanded, label);
        if (!expanded)
        {
            // Don't add the '+' button when the contents are collapsed. Just quit.
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();
            EditorGUI.indentLevel = indent;              // Return to the last indent
            return(expanded);
        }

        // BUTTONS...
        EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(100));

        // Add expand/collapse buttons if there are items in the list
        bool masterCollapse = false;
        bool masterExpand   = false;
        if (list.Count > 0)
        {
            GUIContent content;
            var        collapseIcon = '\u2261'.ToString();
            content        = new GUIContent(collapseIcon, "Click to collapse all");
            masterCollapse = GUILayout.Button(content, EditorStyles.toolbarButton);

            var expandIcon = '\u25A1'.ToString();
            content      = new GUIContent(expandIcon, "Click to expand all");
            masterExpand = GUILayout.Button(content, EditorStyles.toolbarButton);
        }
        else
        {
            GUILayout.FlexibleSpace();
        }

        EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(50));
        // A little space between button groups
        GUILayout.Space(buttonSpacer);

        // Main Add button
        if (GUILayout.Button(new GUIContent("+", "Click to add"), EditorStyles.toolbarButton))
        {
            list.Add(new CharactersActionData());
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndHorizontal();
        #endregion Header Foldout


        #region List Items
        // Use a for, instead of foreach, to avoid the iterator since we will be
        //   be changing the loop in place when buttons are pressed. Even legal
        //   changes can throw an error when changes are detected
        for (int i = 0; i < list.Count; i++)
        {
            CharactersActionData item = list[i];

            #region Section Header
            // If there is a field with the name 'name' use it for our label
            string itemLabel = PGEditorUtils.GetSerializedObjFieldName <CharactersActionData>(item);
            if (itemLabel == "")
            {
                itemLabel = string.Format("Element {0}", i);
            }


            // Get the foldout state.
            //   If this item is new, add it too (singleton)
            //   Singleton works better than multiple Add() calls because we can do
            //   it all at once, and in one place.
            bool foldOutState;
            if (!foldOutStates.TryGetValue(item, out foldOutState))
            {
                foldOutStates[item] = true;
                foldOutState        = true;
            }

            // Force states if master buttons were pressed
            if (masterCollapse)
            {
                foldOutState = false;
            }
            if (masterExpand)
            {
                foldOutState = true;
            }

            // Use a Horizanal space or the toolbar will extend to the start no matter what
            EditorGUILayout.BeginHorizontal();
            EditorGUI.indentLevel = 0;              // Space will handle this for the header
            GUILayout.Space((indent + 3) * 6);      // Matches the content indent

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            // Display foldout with current state
            foldOutState        = PGEditorUtils.Foldout(foldOutState, itemLabel);
            foldOutStates[item] = foldOutState;              // Used again below

            PGEditorUtils.LIST_BUTTONS listButtonPressed = PGEditorUtils.AddFoldOutListItemButtons();

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndHorizontal();

            #endregion Section Header


            // If folded out, display all serialized fields
            if (foldOutState == true)
            {
                EditorGUI.indentLevel = indent + 3;

                // Display Fields for the list instance
//				PGEditorUtils.SerializedObjectFields<T>(item, collapseBools);
                System.Type type = typeof(CharactersActionData);
                //				System.Reflection.FieldInfo[] fields = type.GetFields();

                // Display Fields Dynamically
                item.actionType = PGEditorUtils.EnumPopup <Config.ColliderAction>("actionType", item.actionType);
                item.condition  = PGEditorUtils.EnumPopup <Config.ActionTriggerCondition>("triggerCondition", item.condition);
                PGEditorUtils.FieldInfoField <CharactersActionData>(item, type.GetField("loop"));
                switch (item.actionType)
                {
                case Config.ColliderAction.Movement:
                    drawRegion(x => item.startVal = x, tf.localPosition, x => tf.localPosition = x, item.startVal, item, "startVal");
                    drawRegion(x => item.endVal   = x, tf.localPosition, x => tf.localPosition = x, item.endVal, item, "endVal");
                    break;

                case Config.ColliderAction.Rotation:
                    drawRegion(x => item.startVal    = x, tf.localRotation.eulerAngles,
                               x => tf.localRotation = Quaternion.Euler(item.startVal), item.startVal,
                               item, "startVal");
                    drawRegion(x => item.endVal = x, tf.localRotation.eulerAngles, x => tf.localRotation = x, Quaternion.Euler(item.endVal), item, "endVal");
                    break;

                case Config.ColliderAction.Scale:
                    drawRegion(x => item.startVal = x, tf.localScale, x => tf.localScale = x, item.startVal, item, "startVal");
                    drawRegion(x => item.endVal   = x, tf.localScale, x => tf.localScale = x, item.endVal, item, "endVal");
                    break;

                case Config.ColliderAction.Alpha:
                    PGEditorUtils.FieldInfoField <CharactersActionData>(item, type.GetField("startAlpha"));
                    PGEditorUtils.FieldInfoField <CharactersActionData>(item, type.GetField("endAlpha"));
                    break;
                }
                PGEditorUtils.FieldInfoField <CharactersActionData>(item, type.GetField("duration"));
                if (item.loop > 1 || item.loop < 0)
                {
                    item.loopType = PGEditorUtils.EnumPopup <DG.Tweening.LoopType>("loopType", item.loopType);
                    PGEditorUtils.FieldInfoField <CharactersActionData>(item, type.GetField("pauseTime"));
                }
                PGEditorUtils.FieldInfoField <CharactersActionData>(item, type.GetField("delay"));
                GUILayout.Space(2);
            }



            #region Process List Changes
            // Don't allow 'up' presses for the first list item
            switch (listButtonPressed)
            {
            case PGEditorUtils.LIST_BUTTONS.None:             // Nothing was pressed, do nothing
                break;

            case PGEditorUtils.LIST_BUTTONS.Up:
                if (i > 0)
                {
                    CharactersActionData shiftItem = list[i];
                    list.RemoveAt(i);
                    list.Insert(i - 1, shiftItem);
                }
                break;

            case PGEditorUtils.LIST_BUTTONS.Down:
                // Don't allow 'down' presses for the last list item
                if (i + 1 < list.Count)
                {
                    CharactersActionData shiftItem = list[i];
                    list.RemoveAt(i);
                    list.Insert(i + 1, shiftItem);
                }
                break;

            case PGEditorUtils.LIST_BUTTONS.Remove:
                list.RemoveAt(i);
                foldOutStates.Remove(item);                  // Clean-up
                break;

            case PGEditorUtils.LIST_BUTTONS.Add:
                list.Insert(i, new CharactersActionData());
                break;
            }
            #endregion Process List Changes
        }
        #endregion List Items


        EditorGUI.indentLevel = indent;

        return(expanded);
    }
        protected override void OnInspectorGUIUpdate()
        {
            var script = (WorldTo2DCameraConstraint)target;

            script.targetCamera = PGEditorUtils.ObjectField <Camera>("Target Camera", script.targetCamera);
            script.orthoCamera  = PGEditorUtils.ObjectField <Camera>("Output Camera", script.orthoCamera);

            EditorGUILayout.Space();

            script.offsetMode = PGEditorUtils.EnumPopup <WorldTo2DCameraConstraint.OFFSET_MODE>
                                (
                "Offset Mode",
                script.offsetMode
                                );

            script.offset = EditorGUILayout.Vector3Field("Offset", script.offset);



            EditorGUILayout.Space();

            script.offScreenMode = PGEditorUtils.EnumPopup <WorldTo2DCameraConstraint.OFFSCREEN_MODE>
                                   (
                "Offscreen Mode",
                script.offScreenMode
                                   );

            EditorGUI.indentLevel += 2;
            if (script.offScreenMode != WorldTo2DCameraConstraint.OFFSCREEN_MODE.Constrain)
            {
                script.offscreenThreasholdH =
                    EditorGUILayout.Vector2Field("Height Threashold", script.offscreenThreasholdH);

                script.offscreenThreasholdW =
                    EditorGUILayout.Vector2Field("Width Threashold", script.offscreenThreasholdW);
            }

            EditorGUI.indentLevel -= 2;

            EditorGUILayout.Space();

            base.OnInspectorGUIUpdate();



            // Set some singletone defaults (will only run once)..

            // This will actually run when the inspector changes, but still better than
            //   running every update
            if (this.cameras == null)
            {
                this.cameras = FindObjectsOfType(typeof(Camera)) as Camera[];
            }

            // Default to the first ortho camera that is set to render this object
            if (script.orthoCamera == null)
            {
                foreach (Camera cam in cameras)
                {
                    if (!cam.orthographic)
                    {
                        continue;
                    }

                    if ((cam.cullingMask & 1 << script.gameObject.layer) > 0)
                    {
                        script.orthoCamera = cam;
                        break;
                    }
                }
            }

            // Default to the first camera that is set to render the target
            if (script.target != null && script.targetCamera == null)
            {
                foreach (Camera cam in cameras)
                {
                    if ((cam.cullingMask & 1 << script.target.gameObject.layer) > 0)
                    {
                        script.targetCamera = cam;
                        break;
                    }
                }
            }
        }
Beispiel #9
0
    public override void OnInspectorGUI()
    {
        var script = (Detonator)target;

        GUIStyle style;

        PGEditorUtils.LookLikeControls();
        EditorGUI.indentLevel = 1;

        script.targetLayers = PGEditorUtils.LayerMaskField
                              (
            "Hit Layers",
            script.targetLayers
                              );

        script.perimeterLayer = EditorGUILayout.LayerField("Range Layer", script.perimeterLayer);

        EditorGUILayout.BeginHorizontal();

        // Only trigger the update if it actually changes. This runs code in a peroperty
        //   that may be expensive
        var shape = script.perimeterShape;

        shape = PGEditorUtils.EnumPopup <TargetTracker.PERIMETER_SHAPES>("Detonation Shape", shape);
        if (shape != script.perimeterShape)
        {
            script.perimeterShape = shape;
        }

        script.overrideGizmoVisibility = false;

        GUILayout.Label("Gizmo", GUILayout.MaxWidth(40));
        script.drawGizmo = EditorGUILayout.Toggle(script.drawGizmo, GUILayout.MaxWidth(47));
        EditorGUILayout.EndHorizontal();

        if (script.drawGizmo)
        {
            EditorGUI.indentLevel = 3;
            EditorGUILayout.BeginHorizontal();

            script.gizmoColor = EditorGUILayout.ColorField("Gizmo Color", script.gizmoColor);

            style            = EditorStyles.miniButton;
            style.alignment  = TextAnchor.MiddleCenter;
            style.fixedWidth = 52;

            bool clicked = GUILayout.Toggle(false, "Reset", style);
            if (clicked)
            {
                script.gizmoColor = script.defaultGizmoColor;
            }

            EditorGUILayout.EndHorizontal();

            EditorGUI.indentLevel = 2;

            GUILayout.Space(4);
        }

        script.durration = EditorGUILayout.FloatField("Expand Durration", script.durration);

        // Display some information
        GUILayout.Space(6);
        style           = new GUIStyle(EditorStyles.label);
        style.wordWrap  = true;
        style.fontStyle = FontStyle.Italic;
        GUILayout.Label
        (
            "If spawned by a projectile, " +
            "the folowing range and effects are inherited from the projectile...",
            style
        );


        Vector3 range = script.range;

        switch (script.perimeterShape)
        {
        case TargetTracker.PERIMETER_SHAPES.Sphere:
            range.x = EditorGUILayout.FloatField("Max Range", range.x);
            range.y = range.x;
            range.z = range.x;
            break;

        case TargetTracker.PERIMETER_SHAPES.Box:
            range = EditorGUILayout.Vector3Field("Max Range", range);
            break;

        case TargetTracker.PERIMETER_SHAPES.Capsule:
            range   = EditorGUILayout.Vector2Field("Max Range", range);
            range.z = range.x;
            break;
        }
        script.range = range;

        GUILayout.Space(6);

        this.expandEffects = PGEditorUtils.SerializedObjFoldOutList <HitEffectGUIBacker>
                             (
            "EffectOnTargets",
            script._effectsOnTarget,
            this.expandEffects,
            ref script._editorListItemStates,
            true
                             );

        GUILayout.Space(4);
        script.debugLevel = (DEBUG_LEVELS)EditorGUILayout.EnumPopup("Debug Level", (System.Enum)script.debugLevel);


        // Flag Unity to save the changes to to the prefab to disk
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
    public override void OnInspectorGUI()
    {
        var script = (FireController)target;

        GUIContent content;

        EditorGUI.indentLevel = 1;
        PGEditorUtils.LookLikeControls();

        content         = new GUIContent("Interval", "Fire every X seconds");
        script.interval = EditorGUILayout.FloatField(content, script.interval);

        content = new GUIContent
                  (
            "Init Countdown at 0",
            "Able to fire immediatly when first spawned, before interval count begins"
                  );
        script.initIntervalCountdownAtZero = EditorGUILayout.Toggle(content, script.initIntervalCountdownAtZero);

        content = new GUIContent
                  (
            "Wait For Alignment",
            "Wait for the emitter to line up with the target before fireing. The " +
            "count will continue so this will fire as soon as possible."
                  );
        script.waitForAlignment = EditorGUILayout.Toggle(content, script.waitForAlignment);
        if (script.waitForAlignment)
        {
            EditorGUI.indentLevel = 2;

            script.emitter = PGEditorUtils.ObjectField <Transform>("Emitter (Optional)", script.emitter);

            content = new GUIContent
                      (
                "Angle Tolerance",
                "If waitForAlignment is true: If the emitter is pointing towards " +
                "the target within this angle in degrees, the target can be fired on."
                      );
            script.lockOnAngleTolerance = EditorGUILayout.FloatField(content, script.lockOnAngleTolerance);

            content = new GUIContent
                      (
                "Flat Comparison",
                "If false the true angles will be compared for alignment. " +
                "(More precise. Emitter must point at target.)\n" +
                "If true, only the direction matters. " +
                "(Good when turning in a direction but perfect alignment isn't needed.)"
                      );
            script.flatAngleCompare = EditorGUILayout.Toggle(content, script.flatAngleCompare);

            EditorGUI.indentLevel = 1;
        }

        script.notifyTargets = PGEditorUtils.EnumPopup <FireController.NOTIFY_TARGET_OPTIONS>
                               (
            "Notify Targets",
            script.notifyTargets
                               );

        if (script.notifyTargets > FireController.NOTIFY_TARGET_OPTIONS.Off)
        {
            script.ammoPrefab = PGEditorUtils.ObjectField <Transform>
                                (
                "Ammo (Optional)",
                script.ammoPrefab
                                );
        }


        EditorGUI.indentLevel = 2;

        this.expandEffects = PGEditorUtils.SerializedObjFoldOutList <HitEffectGUIBacker>
                             (
            "EffectOnTargets",
            script._effectsOnTarget,
            this.expandEffects,
            ref script._editorListItemStates,
            true
                             );

        EditorGUI.indentLevel = 1;


        GUILayout.Space(4);
        script.debugLevel = PGEditorUtils.EnumPopup <DEBUG_LEVELS>("Debug Level", script.debugLevel);

        // Flag Unity to save the changes to to the prefab to disk
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Beispiel #11
0
    public override void OnInspectorGUI()
    {
        var script = (LineOfSightModifier)target;

        PGEditorUtils.LookLikeControls();
        EditorGUI.indentLevel = 1;

        // Display some information
        GUILayout.Space(6);
        GUIStyle style = new GUIStyle(EditorStyles.textField);

        style.wordWrap  = true;
        style.fontStyle = FontStyle.Italic;
        style.padding   = new RectOffset(4, 4, 4, 4);
        EditorGUILayout.LabelField
        (
            "Add layers to activate LOS filtering.\n" +
            "  - Target Tracker to ignore targets\n" +
            "  - Fire Controller to hold fire",
            style
        );

        script.targetTrackerLayerMask = PGEditorUtils.LayerMaskField
                                        (
            "Target Tracker Mask",
            script.targetTrackerLayerMask
                                        );

        // Might as well set the component if we are going to do GetComponent.
        //   Also works as a singleton, not that it matters much in Editor scripts.
        if (script.fireCtrl == null)
        {
            script.fireCtrl = script.GetComponent <FireController>();
        }

        if (script.fireCtrl)
        {
            script.fireControllerLayerMask = PGEditorUtils.LayerMaskField
                                             (
                "Fire Controller Mask",
                script.fireControllerLayerMask
                                             );
        }

        GUILayout.Space(6);

        script.testMode = PGEditorUtils.EnumPopup <LineOfSightModifier.TEST_MODE>
                          (
            "LOS Test Mode",
            script.testMode
                          );

        if (script.testMode == LineOfSightModifier.TEST_MODE.SixPoint)
        {
            EditorGUI.indentLevel = 2;
            script.radius         = EditorGUILayout.FloatField("Radius", script.radius);
            EditorGUI.indentLevel = 1;
        }

        GUILayout.Space(4);
        script.debugLevel = (DEBUG_LEVELS)EditorGUILayout.EnumPopup("Debug Level", (System.Enum)script.debugLevel);


        // Flag Unity to save the changes to to the prefab to disk
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Beispiel #12
0
    protected override void OnInspectorGUIUpdate()
    {
        base.OnInspectorGUIUpdate();

        var script = (SmoothTransformConstraint)target;

        GUILayout.BeginHorizontal();

        script.constrainPosition = EditorGUILayout.Toggle("Position", script.constrainPosition);

        if (script.constrainPosition)
        {
            GUIStyle style = EditorStyles.toolbarButton;
            style.alignment    = TextAnchor.MiddleCenter;
            style.stretchWidth = true;

            script.outputPosX = GUILayout.Toggle(script.outputPosX, "X", style);
            script.outputPosY = GUILayout.Toggle(script.outputPosY, "Y", style);
            script.outputPosZ = GUILayout.Toggle(script.outputPosZ, "Z", style);
        }
        GUILayout.EndHorizontal();

        if (script.constrainPosition)
        {
            EditorGUI.indentLevel = 2;
            script.positionSpeed  = EditorGUILayout.FloatField("Percent", script.positionSpeed);
            EditorGUI.indentLevel = 0;
            EditorGUILayout.Space();
        }



        GUILayout.BeginHorizontal();
        script.constrainRotation = EditorGUILayout.Toggle("Rotation", script.constrainRotation);
        if (script.constrainRotation)
        {
            script.output = PGEditorUtils.EnumPopup <UnityConstraints.OUTPUT_ROT_OPTIONS>(script.output);
        }
        GUILayout.EndHorizontal();

        if (script.constrainRotation)
        {
            EditorGUI.indentLevel = 2;
            script.rotationSpeed  = EditorGUILayout.FloatField("Speed", script.rotationSpeed);
            script.interpolation  = PGEditorUtils.EnumPopup <UnityConstraints.INTERP_OPTIONS>
                                    (
                "Interpolation Mode",
                script.interpolation
                                    );
            EditorGUI.indentLevel = 0;
            EditorGUILayout.Space();
        }


        script.constrainScale = EditorGUILayout.Toggle("Scale", script.constrainScale);
        if (script.constrainScale)
        {
            EditorGUI.indentLevel = 2;
            script.scaleSpeed     = EditorGUILayout.FloatField("Percent", script.scaleSpeed);
            EditorGUI.indentLevel = 0;
            EditorGUILayout.Space();
        }
    }
Beispiel #13
0
    public override void OnInspectorGUI()
    {
        var script = (Projectile)target;

        PGEditorUtils.LookLikeControls();
        GUIContent content;

        EditorGUI.indentLevel = 1;

        script.targetLayers = PGEditorUtils.LayerMaskField
                              (
            "Hit Layers",
            script.targetLayers
                              );

        script.detonationMode = PGEditorUtils.EnumPopup <Projectile.DETONATION_MODES>
                                (
            "Detonation Mode",
            script.detonationMode
                                );

        content = new GUIContent
                  (
            "Timer (0 = OFF)",
            "An optional timer (in seconds) to detonate this " +
            "projectile if it expires."
                  );
        script.timer = EditorGUILayout.FloatField(content, script.timer);

        content = new GUIContent
                  (
            "Detonate On Sleep",
            "If the projectile has a rigidbody, this will detonate it if it falls " +
            "asleep. See Unity's docs for more information on how this happens."
                  );
        script.detonateOnRigidBodySleep = EditorGUILayout.Toggle(content,
                                                                 script.detonateOnRigidBodySleep);

        content        = new GUIContent("Area Hit", "True to an area, not just a single target");
        script.areaHit = EditorGUILayout.Toggle(content, script.areaHit);

        if (script.areaHit)
        {
            EditorGUI.indentLevel  = 2;
            script.numberOfTargets = EditorGUILayout.IntField("Targets (-1 for all)", script.numberOfTargets);

            script.sortingStyle = PGEditorUtils.EnumPopup <TargetTracker.SORTING_STYLES>
                                  (
                "Sorting Style",
                script.sortingStyle
                                  );


            if (script.sortingStyle != TargetTracker.SORTING_STYLES.None)
            {
                EditorGUI.indentLevel = 3;
                script.sortInterval   = EditorGUILayout.FloatField("Min Interval", script.sortInterval);
                EditorGUI.indentLevel = 2;
            }

            script.perimeterLayer = EditorGUILayout.LayerField("Range Layer", script.perimeterLayer);

            EditorGUILayout.BeginHorizontal();

            // Only trigger the update if it actually changes. This runs code in a peroperty
            //   that may be expensive
            var shape = script.perimeterShape;
            shape = PGEditorUtils.EnumPopup <TargetTracker.PERIMETER_SHAPES>("Perimeter Shape", shape);
            if (shape != script.perimeterShape)
            {
                script.perimeterShape = shape;
            }

            script.overrideGizmoVisibility = false;

            GUILayout.Label("Gizmo", GUILayout.MaxWidth(40));
            script.drawGizmo = EditorGUILayout.Toggle(script.drawGizmo, GUILayout.MaxWidth(47));
            EditorGUILayout.EndHorizontal();

            if (script.drawGizmo)
            {
                EditorGUI.indentLevel = 3;
                EditorGUILayout.BeginHorizontal();

                script.gizmoColor = EditorGUILayout.ColorField("Gizmo Color", script.gizmoColor);

                GUIStyle style = EditorStyles.miniButton;
                style.alignment  = TextAnchor.MiddleCenter;
                style.fixedWidth = 52;

                bool clicked = GUILayout.Toggle(false, "Reset", style);
                if (clicked)
                {
                    script.gizmoColor = script.defaultGizmoColor;
                }

                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel = 2;

                GUILayout.Space(4);
            }

            Vector3 range = script.range;
            switch (script.perimeterShape)
            {
            case TargetTracker.PERIMETER_SHAPES.Sphere:
                range.x = EditorGUILayout.FloatField("Range", range.x);
                range.y = range.x;
                range.z = range.x;
                break;

            case TargetTracker.PERIMETER_SHAPES.Box:
                range = EditorGUILayout.Vector3Field("Range", range);
                break;

            case TargetTracker.PERIMETER_SHAPES.Capsule:
                range   = EditorGUILayout.Vector2Field("Range", range);
                range.z = range.x;
                break;
            }
            script.range = range;


            //script.perimeterPositionOffset = EditorGUILayout.Vector3Field("Position Offset", script.perimeterPositionOffset);
            //script.perimeterRotationOffset = EditorGUILayout.Vector3Field("Rotation Offset", script.perimeterRotationOffset);
            GUILayout.Space(8);
        }
        else
        {
            script.overrideGizmoVisibility = true;
        }

        EditorGUI.indentLevel = 1;

        script.notifyTargets = PGEditorUtils.EnumPopup <Projectile.NOTIFY_TARGET_OPTIONS>
                               (
            "Notify Targets",
            script.notifyTargets
                               );

        script.detonationPrefab = PGEditorUtils.ObjectField <Transform>
                                  (
            "Spawn On Detonation",
            script.detonationPrefab
                                  );

        EditorGUI.indentLevel = 2;

        this.expandEffects = PGEditorUtils.SerializedObjFoldOutList <HitEffectGUIBacker>
                             (
            "EffectOnTargets   (May be inherited)",
            script._effectsOnTarget,
            this.expandEffects,
            ref script._editorListItemStates,
            true
                             );

        GUILayout.Space(4);
        script.debugLevel = (DEBUG_LEVELS)EditorGUILayout.EnumPopup("Debug Level", (System.Enum)script.debugLevel);


        // Flag Unity to save the changes to to the prefab to disk
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }