コード例 #1
0
    protected override void OnInspectorGUIHeader()
    {
        base.OnInspectorGUIHeader();
        var script = (ConstraintBaseClass)target;

        script.target = PGEditorUtils.ObjectField <Transform>("Target", script.target);
    }
コード例 #2
0
    protected override void OnInspectorGUIUpdate()
    {
        base.OnInspectorGUIUpdate();

        var script = (LookAtConstraint)target;

        script.upTarget = PGEditorUtils.ObjectField <Transform>("Up Target (Optional)", script.upTarget);
    }
コード例 #3
0
    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
                        );
    }
コード例 #4
0
    public override void OnInspectorGUI()
    {
        var script = (SpawnPool)target;

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

        script.poolName = EditorGUILayout.TextField("Pool Name", script.poolName);

        script.DespawnHolderTF = PGEditorUtils.ObjectField <Transform>("DespawnHolderTF", script.DespawnHolderTF);
        script.SpawnHolderTF   = PGEditorUtils.ObjectField <Transform>("SpawnHolderTF", script.SpawnHolderTF);

        script.matchPoolScale = EditorGUILayout.Toggle("Match Pool Scale", script.matchPoolScale);
        script.matchPoolLayer = EditorGUILayout.Toggle("Match Pool Layer", script.matchPoolLayer);

        script.dontReparent = EditorGUILayout.Toggle("Don't Reparent", script.dontReparent);

        script._dontDestroyOnLoad = EditorGUILayout.Toggle("Don't Destroy On Load", script._dontDestroyOnLoad);

        script.logMessages = EditorGUILayout.Toggle("Log Messages", script.logMessages);

        this.expandPrefabs = PGEditorUtils.SerializedObjFoldOutList <PrefabPool>
                             (
            "Per-Prefab Pool Options",
            script._perPrefabPoolOptions,
            this.expandPrefabs,
            ref script._editorListItemStates,
            true
                             );

        // Flag Unity to save the changes to to the prefab to disk
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
コード例 #5
0
    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);
        }
    }
コード例 #6
0
        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;
                    }
                }
            }
        }
コード例 #7
0
    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);
        }
    }
コード例 #8
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);
        }
    }