Example #1
0
        public override void OnInspectorGUI()
        {
            Player _target = (Player)target;

            SharedGUIOne(_target);

            SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;

            if (settingsManager != null && settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                NPC_GUI(_target);
            }

            SharedGUITwo(_target);

            if (settingsManager && (settingsManager.hotspotDetection == HotspotDetection.PlayerVicinity || settingsManager.playerSwitching == PlayerSwitching.Allow))
            {
                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.LabelField("Player settings", EditorStyles.boldLabel);

                if (settingsManager.hotspotDetection == HotspotDetection.PlayerVicinity)
                {
                    _target.hotspotDetector = (DetectHotspots)CustomGUILayout.ObjectField <DetectHotspots> ("Hotspot detector child:", _target.hotspotDetector, true, "", "The DetectHotspots component to rely on for hotspot detection. This should be a child object of the Player.");
                }

                if (settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    _target.autoSyncHotspotState = CustomGUILayout.Toggle("Auto-sync Hotspot state?", _target.autoSyncHotspotState, "", "If True, then any attached Hotspot will be made inactive while this character is the current active Player");
                }

                EditorGUILayout.EndVertical();
            }

            if (Application.isPlaying && _target.gameObject.activeInHierarchy)
            {
                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.LabelField("Current inventory", EditorStyles.boldLabel);

                bool isCarrying = false;

                if (KickStarter.saveSystem != null)
                {
                    if ((_target.IsLocalPlayer() ||
                         KickStarter.settingsManager.playerSwitching == PlayerSwitching.DoNotAllow ||
                         _target.ID == KickStarter.saveSystem.CurrentPlayerID ||
                         KickStarter.settingsManager.shareInventory))
                    {
                        if (KickStarter.runtimeInventory != null && KickStarter.runtimeInventory.localItems != null)
                        {
                            if (ListItems(KickStarter.runtimeInventory.localItems))
                            {
                                isCarrying = true;
                            }
                        }

                        if (KickStarter.inventoryManager != null && KickStarter.runtimeDocuments != null && KickStarter.runtimeDocuments.GetCollectedDocumentIDs() != null)
                        {
                            for (int i = 0; i < KickStarter.runtimeDocuments.GetCollectedDocumentIDs().Length; i++)
                            {
                                Document document = KickStarter.inventoryManager.GetDocument(KickStarter.runtimeDocuments.GetCollectedDocumentIDs()[i]);

                                if (document != null)
                                {
                                    isCarrying = true;

                                    EditorGUILayout.BeginHorizontal();
                                    EditorGUILayout.LabelField("Document:", GUILayout.Width(80f));
                                    EditorGUILayout.LabelField(document.Title, EditorStyles.boldLabel);
                                    EditorGUILayout.EndHorizontal();
                                }
                            }
                        }

                        if (KickStarter.inventoryManager != null && KickStarter.runtimeObjectives != null)
                        {
                            ObjectiveInstance[] objectiveInstances = KickStarter.runtimeObjectives.GetObjectives();
                            foreach (ObjectiveInstance objectiveInstance in objectiveInstances)
                            {
                                EditorGUILayout.BeginHorizontal();
                                EditorGUILayout.LabelField("Objective:", GUILayout.Width(80f));
                                EditorGUILayout.LabelField(objectiveInstance.Objective.GetTitle() + ": " + objectiveInstance.CurrentState.GetLabel(), EditorStyles.boldLabel);
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                    }
                    else
                    {
                        PlayerData playerData = KickStarter.saveSystem.GetPlayerData(_target.ID);
                        if (playerData != null)
                        {
                            List <InvItem> items = KickStarter.saveSystem.AssignInventory(playerData.inventoryData);
                            if (ListItems(items))
                            {
                                isCarrying = true;
                            }

                            if (!string.IsNullOrEmpty(playerData.collectedDocumentData))
                            {
                                EditorGUILayout.LabelField("Documents:", playerData.collectedDocumentData);
                            }
                            if (!string.IsNullOrEmpty(playerData.playerObjectivesData))
                            {
                                EditorGUILayout.LabelField("Objectives:", playerData.playerObjectivesData);
                            }
                        }
                    }
                }

                if (!isCarrying)
                {
                    EditorGUILayout.HelpBox("This Player is not carrying any items.", MessageType.Info);
                }

                EditorGUILayout.EndVertical();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
        public override void OnInspectorGUI()
        {
            GameCameraAnimated _target = (GameCameraAnimated)target;

            if (_target.GetComponent <Animation>() == null)
            {
                EditorGUILayout.HelpBox("This camera type requires an Animation component.", MessageType.Warning);
            }

            EditorGUILayout.BeginVertical("Button");
            _target.animatedCameraType = (AnimatedCameraType)EditorGUILayout.EnumPopup("Animated camera type:", _target.animatedCameraType);
            _target.clip = (AnimationClip)EditorGUILayout.ObjectField("Animation clip:", _target.clip, typeof(AnimationClip), false);

            if (_target.animatedCameraType == AnimatedCameraType.PlayWhenActive)
            {
                _target.loopClip    = EditorGUILayout.Toggle("Loop animation?", _target.loopClip);
                _target.playOnStart = EditorGUILayout.Toggle("Play on start?", _target.playOnStart);
            }
            else if (_target.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement)
            {
                _target.pathToFollow   = (Paths)EditorGUILayout.ObjectField("Path to follow:", _target.pathToFollow, typeof(Paths), true);
                _target.targetIsPlayer = EditorGUILayout.Toggle("Target is Player?", _target.targetIsPlayer);

                if (!_target.targetIsPlayer)
                {
                    _target.target = (Transform)EditorGUILayout.ObjectField("Target:", _target.target, typeof(Transform), true);
                }
            }
            EditorGUILayout.EndVertical();

            if (_target.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement)
            {
                EditorGUILayout.Space();
                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.LabelField("Cursor influence", EditorStyles.boldLabel);
                _target.followCursor = EditorGUILayout.Toggle("Follow cursor?", _target.followCursor);
                if (_target.followCursor)
                {
                    _target.cursorInfluence           = EditorGUILayout.Vector2Field("Panning factor", _target.cursorInfluence);
                    _target.constrainCursorInfluenceX = EditorGUILayout.ToggleLeft("Constrain panning in X direction?", _target.constrainCursorInfluenceX);
                    if (_target.constrainCursorInfluenceX)
                    {
                        _target.limitCursorInfluenceX[0] = EditorGUILayout.Slider("Minimum X:", _target.limitCursorInfluenceX[0], -1.4f, 0f);
                        _target.limitCursorInfluenceX[1] = EditorGUILayout.Slider("Maximum X:", _target.limitCursorInfluenceX[1], 0f, 1.4f);
                    }
                    _target.constrainCursorInfluenceY = EditorGUILayout.ToggleLeft("Constrain panning in Y direction?", _target.constrainCursorInfluenceY);
                    if (_target.constrainCursorInfluenceY)
                    {
                        _target.limitCursorInfluenceY[0] = EditorGUILayout.Slider("Minimum Y:", _target.limitCursorInfluenceY[0], -1.4f, 0f);
                        _target.limitCursorInfluenceY[1] = EditorGUILayout.Slider("Maximum Y:", _target.limitCursorInfluenceY[1], 0f, 1.4f);
                    }

                    if (Application.isPlaying && KickStarter.mainCamera != null && KickStarter.mainCamera.attachedCamera == _target)
                    {
                        EditorGUILayout.HelpBox("Changes made to this panel will not be felt until the MainCamera switches to this camera again.", MessageType.Info);
                    }
                }
                EditorGUILayout.EndVertical();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
        public override void OnInspectorGUI()
        {
            GameCamera _target = (GameCamera)target;

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Cursor influence", EditorStyles.boldLabel);
            _target.followCursor = EditorGUILayout.Toggle("Follow cursor?", _target.followCursor);
            if (_target.followCursor)
            {
                _target.cursorInfluence           = EditorGUILayout.Vector2Field("Panning factor:", _target.cursorInfluence);
                _target.constrainCursorInfluenceX = EditorGUILayout.ToggleLeft("Constrain panning in X direction?", _target.constrainCursorInfluenceX);
                if (_target.constrainCursorInfluenceX)
                {
                    _target.limitCursorInfluenceX[0] = EditorGUILayout.Slider("Minimum X:", _target.limitCursorInfluenceX[0], -1.4f, 0f);
                    _target.limitCursorInfluenceX[1] = EditorGUILayout.Slider("Maximum X:", _target.limitCursorInfluenceX[1], 0f, 1.4f);
                }
                _target.constrainCursorInfluenceY = EditorGUILayout.ToggleLeft("Constrain panning in Y direction?", _target.constrainCursorInfluenceY);
                if (_target.constrainCursorInfluenceY)
                {
                    _target.limitCursorInfluenceY[0] = EditorGUILayout.Slider("Minimum Y:", _target.limitCursorInfluenceY[0], -1.4f, 0f);
                    _target.limitCursorInfluenceY[1] = EditorGUILayout.Slider("Maximum Y:", _target.limitCursorInfluenceY[1], 0f, 1.4f);
                }

                if (Application.isPlaying && KickStarter.mainCamera != null && KickStarter.mainCamera.attachedCamera == _target)
                {
                    EditorGUILayout.HelpBox("Changes made to this panel will not be felt until the MainCamera switches to this camera again.", MessageType.Info);
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("X-axis movement", EditorStyles.boldLabel);

            _target.lockXLocAxis = EditorGUILayout.Toggle("Lock?", _target.lockXLocAxis);

            if (!_target.lockXLocAxis)
            {
                _target.xLocConstrainType = (CameraLocConstrainType)EditorGUILayout.EnumPopup("Affected by:", _target.xLocConstrainType);

                EditorGUILayout.BeginVertical("Button");
                if (_target.xLocConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    _target.xFreedom = EditorGUILayout.FloatField("Track freedom:", _target.xFreedom);
                }
                else
                {
                    _target.xGradient = EditorGUILayout.FloatField("Influence:", _target.xGradient);
                    _target.xOffset   = EditorGUILayout.FloatField("Offset:", _target.xOffset);
                }
                EditorGUILayout.EndVertical();

                _target.limitX = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitX);

                EditorGUILayout.BeginVertical("Button");
                _target.constrainX[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainX[0]);
                _target.constrainX[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainX[1]);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndToggleGroup();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Y-axis movement", EditorStyles.boldLabel);

            _target.lockYLocAxis = EditorGUILayout.Toggle("Lock?", _target.lockYLocAxis);

            if (!_target.lockYLocAxis)
            {
                _target.yLocConstrainType = (CameraLocConstrainType)EditorGUILayout.EnumPopup("Affected by:", _target.yLocConstrainType);

                if (_target.yLocConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    EditorGUILayout.HelpBox("This option is not available for Y-movement", MessageType.Warning);
                }
                else
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.yGradientLoc = EditorGUILayout.FloatField("Influence:", _target.yGradientLoc);
                    _target.yOffsetLoc   = EditorGUILayout.FloatField("Offset:", _target.yOffsetLoc);
                    EditorGUILayout.EndVertical();
                }

                _target.limitYLoc = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitYLoc);

                EditorGUILayout.BeginVertical("Button");
                _target.constrainYLoc[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainYLoc[0]);
                _target.constrainYLoc[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainYLoc[1]);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndToggleGroup();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Z-axis movement", EditorStyles.boldLabel);

            _target.lockZLocAxis = EditorGUILayout.Toggle("Lock?", _target.lockZLocAxis);

            if (!_target.lockZLocAxis)
            {
                _target.zLocConstrainType = (CameraLocConstrainType)EditorGUILayout.EnumPopup("Affected by:", _target.zLocConstrainType);

                EditorGUILayout.BeginVertical("Button");
                if (_target.zLocConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    _target.zFreedom = EditorGUILayout.FloatField("Track freedom:", _target.zFreedom);
                }
                else
                {
                    _target.zGradient = EditorGUILayout.FloatField("Influence:", _target.zGradient);
                    _target.zOffset   = EditorGUILayout.FloatField("Offset:", _target.zOffset);
                }
                EditorGUILayout.EndVertical();

                _target.limitZ = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitZ);

                EditorGUILayout.BeginVertical("Button");
                _target.constrainZ[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainZ[0]);
                _target.constrainZ[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainZ[1]);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndToggleGroup();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Pitch rotation", EditorStyles.boldLabel);

            _target.lockXRotAxis = EditorGUILayout.Toggle("Lock?", _target.lockXRotAxis);

            if (!_target.lockXRotAxis)
            {
                _target.xRotConstrainType = (CameraLocConstrainType)EditorGUILayout.EnumPopup("Affected by:", _target.xRotConstrainType);

                if (_target.xRotConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    EditorGUILayout.HelpBox("This option is not available for Pitch rotation", MessageType.Warning);
                }
                else
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.xGradientRot = EditorGUILayout.FloatField("Influence:", _target.xGradientRot);
                    _target.xOffsetRot   = EditorGUILayout.FloatField("Offset:", _target.xOffsetRot);
                    EditorGUILayout.EndVertical();
                }

                _target.limitXRot = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitXRot);

                EditorGUILayout.BeginVertical("Button");
                _target.constrainXRot[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainXRot[0]);
                _target.constrainXRot[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainXRot[1]);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndToggleGroup();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Spin rotation", EditorStyles.boldLabel);

            _target.lockYRotAxis = EditorGUILayout.Toggle("Lock?", _target.lockYRotAxis);

            if (!_target.lockYRotAxis)
            {
                _target.yRotConstrainType = (CameraRotConstrainType)EditorGUILayout.EnumPopup("Affected by:", _target.yRotConstrainType);

                if (_target.yRotConstrainType != CameraRotConstrainType.LookAtTarget)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.directionInfluence = EditorGUILayout.FloatField("Target direction fac.:", _target.directionInfluence);
                    _target.yGradient          = EditorGUILayout.FloatField("Influence:", _target.yGradient);
                    _target.yOffset            = EditorGUILayout.FloatField("Offset:", _target.yOffset);
                    EditorGUILayout.EndVertical();

                    _target.limitY = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitY);

                    EditorGUILayout.BeginVertical("Button");
                    _target.constrainY[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainY[0]);
                    _target.constrainY[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainY[1]);
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.EndToggleGroup();
                }
                else
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.directionInfluence = EditorGUILayout.FloatField("Target direction fac.:", _target.directionInfluence);
                    _target.targetHeight       = EditorGUILayout.FloatField("Target height offset:", _target.targetHeight);
                    _target.targetXOffset      = EditorGUILayout.FloatField("Target X offset:", _target.targetXOffset);
                    _target.targetZOffset      = EditorGUILayout.FloatField("Target Z offset:", _target.targetZOffset);
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            if (_target.GetComponent <Camera>() && _target.GetComponent <Camera>().orthographic)
            {
                EditorGUILayout.LabelField("Orthographic size", EditorStyles.boldLabel);
            }
            else
            {
                EditorGUILayout.LabelField("Field of view", EditorStyles.boldLabel);
            }

            _target.lockFOV = EditorGUILayout.Toggle("Lock?", _target.lockFOV);

            if (!_target.lockFOV)
            {
                EditorGUILayout.HelpBox("This value will vary with the target's distance from the camera.", MessageType.Info);

                EditorGUILayout.BeginVertical("Button");
                _target.FOVGradient = EditorGUILayout.FloatField("Influence:", _target.FOVGradient);
                _target.FOVOffset   = EditorGUILayout.FloatField("Offset:", _target.FOVOffset);
                EditorGUILayout.EndVertical();

                _target.limitFOV = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitFOV);

                EditorGUILayout.BeginVertical("Button");
                _target.constrainFOV[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainFOV[0]);
                _target.constrainFOV[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainFOV[1]);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndToggleGroup();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Depth of field", EditorStyles.boldLabel);
            _target.focalPointIsTarget = EditorGUILayout.Toggle("Focal point is target object?", _target.focalPointIsTarget);
            if (!_target.focalPointIsTarget)
            {
                _target.focalDistance = EditorGUILayout.FloatField("Focal distance:", _target.focalDistance);
            }
            else if (Application.isPlaying)
            {
                EditorGUILayout.LabelField("Focal distance: " + _target.focalDistance.ToString(), EditorStyles.miniLabel);
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            if (!_target.lockXLocAxis || !_target.lockYRotAxis || !_target.lockFOV || !_target.lockYLocAxis || !_target.lockZLocAxis || _target.focalPointIsTarget)
            {
                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.LabelField("Target object to control camera movement", EditorStyles.boldLabel);

                _target.targetIsPlayer = EditorGUILayout.Toggle("Target is player?", _target.targetIsPlayer);

                if (!_target.targetIsPlayer)
                {
                    _target.target = (Transform)EditorGUILayout.ObjectField("Target:", _target.target, typeof(Transform), true);
                }

                _target.dampSpeed = EditorGUILayout.FloatField("Follow speed", _target.dampSpeed);
                _target.actFromDefaultPlayerStart = EditorGUILayout.Toggle("Use default PlayerStart?", _target.actFromDefaultPlayerStart);
                EditorGUILayout.EndVertical();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
Example #4
0
        public override void OnInspectorGUI()
        {
            Paths _target = (Paths)target;

            if (_target.GetComponent <AC.Char>())
            {
                return;
            }

            int numNodes = _target.nodes.Count;

            if (numNodes < 1)
            {
                numNodes      = 1;
                _target.nodes = ResizeList(_target.nodes, numNodes);
            }

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Path properties", EditorStyles.boldLabel);
            _target.nodePause = CustomGUILayout.FloatField("Node wait time (s):", _target.nodePause, "", "The time, in seconds, that a character will wait at each node before continuing along the path");
            _target.pathSpeed = (PathSpeed)CustomGUILayout.EnumPopup("Walk or run:", _target.pathSpeed, "", "The speed at which characters will traverse a path");
            _target.pathType  = (AC_PathType)CustomGUILayout.EnumPopup("Path type:", _target.pathType, "", "The way in which characters move between each node");
            if (_target.pathType == AC_PathType.Loop)
            {
                _target.teleportToStart = CustomGUILayout.Toggle("Teleports when looping?", _target.teleportToStart, "", "If True, then the character will teleport to the first node before traversing the path");
            }
            _target.affectY       = CustomGUILayout.Toggle("Override gravity?", _target.affectY, "", "If True, then characters will attempt to move vertically to reach nodes");
            _target.commandSource = (ActionListSource)CustomGUILayout.EnumPopup("Node commands source:", _target.commandSource, "", "The source of ActionList objects that are run when nodes are reached");
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            // List nodes
            ResetCommandList(_target);

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            EditorGUILayout.LabelField("Origin node:");
            ShowNodeCommandGUI(_target, 0);
            EditorGUILayout.EndVertical();

            for (int i = 1; i < _target.nodes.Count; i++)
            {
                EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                EditorGUILayout.BeginHorizontal();

                if (_target.RelativeMode)
                {
                    EditorGUILayout.LabelField("Node " + i + ": " + _target.nodes[i].ToString());
                }
                else
                {
                    _target.nodes[i] = CustomGUILayout.Vector3Field("Node " + i + ": ", _target.nodes[i], "", "");
                }

                if (GUILayout.Button(insertContent, EditorStyles.miniButtonLeft, buttonWidth))
                {
                    Undo.RecordObject(_target, "Add path node");
                    Vector3 newNodePosition;
                    newNodePosition = _target.nodes[i] + new Vector3(1.0f, 0f, 0f);

                    if (i < (_target.nodes.Count - 1) && _target.nodes[i] != _target.nodes[i + 1])
                    {
                        newNodePosition = (_target.nodes[i] + _target.nodes[i + 1]) / 2f;
                    }

                    _target.nodes.Insert(i + 1, newNodePosition);
                    _target.nodeCommands.Insert(i + 1, new NodeCommand());
                    numNodes += 1;
                    ResetCommandList(_target);
                }
                if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                {
                    Undo.RecordObject(_target, "Delete path node");
                    _target.nodes.RemoveAt(i);
                    _target.nodeCommands.RemoveAt(i);
                    numNodes -= 1;
                    ResetCommandList(_target);
                }

                EditorGUILayout.EndHorizontal();
                ShowNodeCommandGUI(_target, i);
                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add node"))
            {
                Undo.RecordObject(_target, "Add path node");
                numNodes += 1;
            }

            if (numNodes > 1)
            {
                bool newRelativeMode = GUILayout.Toggle(_target.RelativeMode, "Lock relative positions?", "Button");
                if (newRelativeMode && _target.RelativeMode != newRelativeMode)
                {
                    _target.LastFramePosition = _target.transform.position;
                }
                _target.RelativeMode = newRelativeMode;
            }
            else
            {
                _target.RelativeMode = false;
            }
            EditorGUILayout.EndHorizontal();

            if (_target.RelativeMode)
            {
                EditorGUILayout.HelpBox("Before saving/exiting the scene, unlock the above button once nodes have been repositioned.", MessageType.Warning);
            }

            _target.nodes[0] = _target.transform.position;
            _target.nodes    = ResizeList(_target.nodes, numNodes);

            UnityVersionHandler.CustomSetDirty(_target);
        }
Example #5
0
        public override void OnInspectorGUI()
        {
            if (AdvGame.GetReferences() == null)
            {
                ACDebug.LogError("A References file is required - please use the Adventure Creator window to create one.");
                EditorGUILayout.LabelField("No References file found!");
            }
            else
            {
                if (AdvGame.GetReferences().inventoryManager)
                {
                    inventoryManager = AdvGame.GetReferences().inventoryManager;
                }
                if (AdvGame.GetReferences().cursorManager)
                {
                    cursorManager = AdvGame.GetReferences().cursorManager;
                }
                if (AdvGame.GetReferences().settingsManager)
                {
                    settingsManager = AdvGame.GetReferences().settingsManager;
                }

                if (Application.isPlaying)
                {
                    if (_target.gameObject.layer != LayerMask.NameToLayer(settingsManager.hotspotLayer))
                    {
                        EditorGUILayout.HelpBox("Current state: OFF", MessageType.Info);
                    }
                }

                if (_target.lineID > -1)
                {
                    EditorGUILayout.LabelField("Speech Manager ID:", _target.lineID.ToString());
                }

                _target.interactionSource = (AC.InteractionSource)CustomGUILayout.EnumPopup("Interaction source:", _target.interactionSource, "", "The source of the commands that are run when an option is chosen");
                _target.hotspotName       = CustomGUILayout.TextField("Label (if not name):", _target.hotspotName, "", "The display name, if not the GameObject's name");
                _target.highlight         = (Highlight)CustomGUILayout.ObjectField <Highlight> ("Object to highlight:", _target.highlight, true, "", "The Highlight component that controls any highlighting effects associated with the Hotspot");

                if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.hotspotDrawing == ScreenWorld.WorldSpace)
                {
                    _target.iconSortingLayer = CustomGUILayout.TextField("Icon sorting layer:", _target.iconSortingLayer, "", "The 'Sorting Layer' of the icon's SpriteRenderer");
                    _target.iconSortingOrder = CustomGUILayout.IntField("Icon sprite order:", _target.iconSortingOrder, "", "The 'Order in Layer' of the icon's SpriteRenderer");
                }

                EditorGUILayout.BeginHorizontal();
                _target.centrePoint = (Transform)CustomGUILayout.ObjectField <Transform> ("Centre point (override):", _target.centrePoint, true, "", "A Transform that represents the centre of the Hotspot, if it is not physically at the same point as the Hotspot's GameObject itself");

                if (_target.centrePoint == null)
                {
                    if (GUILayout.Button("Create", autoWidth))
                    {
                        string     prefabName = "Hotspot centre: " + _target.gameObject.name;
                        GameObject go         = SceneManager.AddPrefab("Navigation", "HotspotCentre", true, false, false);
                        go.name = prefabName;
                        go.transform.position = _target.transform.position;
                        _target.centrePoint   = go.transform;
                        if (GameObject.Find("_Markers"))
                        {
                            go.transform.parent = GameObject.Find("_Markers").transform;
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                _target.walkToMarker = (Marker)CustomGUILayout.ObjectField <Marker> ("Walk-to Marker:", _target.walkToMarker, true, "", "The Marker that the player can optionally automatically walk to before an Interaction runs");
                if (_target.walkToMarker == null)
                {
                    if (GUILayout.Button("Create", autoWidth))
                    {
                        string prefabName = "Marker";
                        if (SceneSettings.IsUnity2D())
                        {
                            prefabName += "2D";
                        }
                        Marker newMarker = SceneManager.AddPrefab("Navigation", prefabName, true, false, true).GetComponent <Marker>();
                        newMarker.gameObject.name   += (": " + _target.gameObject.name);
                        newMarker.transform.position = _target.transform.position;
                        _target.walkToMarker         = newMarker;
                    }
                }
                EditorGUILayout.EndHorizontal();

                _target.limitToCamera = (_Camera)CustomGUILayout.ObjectField <_Camera> ("Limit to camera:", _target.limitToCamera, true, "", "If assigned, then the Hotspot will only be interactive when the assigned _Camera is active");

                EditorGUILayout.BeginHorizontal();
                _target.interactiveBoundary = (InteractiveBoundary)CustomGUILayout.ObjectField <InteractiveBoundary> ("Interactive boundary:", _target.interactiveBoundary, true, "", "If assigned, then the Hotspot will only be interactive when the player is within this Trigger Collider's boundary");
                if (_target.interactiveBoundary == null)
                {
                    if (GUILayout.Button("Create", autoWidth))
                    {
                        string prefabName = "InteractiveBoundary";
                        if (SceneSettings.IsUnity2D())
                        {
                            prefabName += "2D";
                        }
                        InteractiveBoundary newInteractiveBoundary = SceneManager.AddPrefab("Logic", prefabName, true, false, true).GetComponent <InteractiveBoundary>();
                        newInteractiveBoundary.gameObject.name   += (": " + _target.gameObject.name);
                        newInteractiveBoundary.transform.position = _target.transform.position;
                        _target.interactiveBoundary = newInteractiveBoundary;

                        UnityVersionHandler.PutInFolder(newInteractiveBoundary.gameObject, "_Hotspots");
                    }
                }
                EditorGUILayout.EndHorizontal();

                _target.drawGizmos = CustomGUILayout.Toggle("Draw yellow cube?", _target.drawGizmos, "", "If True, then a Gizmo may be drawn in the Scene window at the Hotspots's position");

                if (settingsManager != null && (settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction || settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot || settingsManager.interactionMethod == AC_InteractionMethod.CustomScript))
                {
                    _target.oneClick = CustomGUILayout.Toggle("Single 'Use' Interaction?", _target.oneClick, "", "If True, then clicking the Hotspot will run the Hotspot's first interaction in useButtons, regardless of the Settings Manager's Interaction method");

                    if (_target.oneClick && settingsManager.interactionMethod == AC_InteractionMethod.CustomScript)
                    {
                        EditorGUILayout.HelpBox("The above property can be accessed by reading the Hotspot script's IsSingleInteraction() method.", MessageType.Info);
                    }
                }
                if (_target.oneClick || (settingsManager != null && settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive))
                {
                    if (settingsManager != null && settingsManager.interactionMethod == AC_InteractionMethod.CustomScript)
                    {
                    }
                    else
                    {
                        _target.doubleClickingHotspot = (DoubleClickingHotspot)CustomGUILayout.EnumPopup("Double-clicking:", _target.doubleClickingHotspot, "", "The effect that double-clicking on the Hotspot has");
                    }
                }
                if (settingsManager != null && settingsManager.playerFacesHotspots)
                {
                    _target.playerTurnsHead = CustomGUILayout.Toggle("Players turn heads when active?", _target.playerTurnsHead, "", "If True, then the player will turn their head when the Hotspot is selected");
                }

                EditorGUILayout.Space();

                UseInteractionGUI();

                if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive || settingsManager.interactionMethod == AC_InteractionMethod.CustomScript)
                {
                    EditorGUILayout.Space();
                    LookInteractionGUI();
                }

                EditorGUILayout.Space();
                InvInteractionGUI();

                EditorGUILayout.Space();
                UnhandledInvInteractionGUI();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
Example #6
0
 /**
  * <summary>Loads the scene asynchronously.</summary>
  * <returns>The generated AsyncOperation class</returns>
  */
 public AsyncOperation LoadLevelASync()
 {
     return(UnityVersionHandler.LoadLevelAsync(number, name));
 }
Example #7
0
        /**
         * Updates the cursor. This is called every frame by StateHandler.
         */
        public void UpdateCursor()
        {
            if (KickStarter.cursorManager.cursorRendering == CursorRendering.Software)
            {
                bool shouldShowCursor = false;

                if (!canShowHardwareCursor)
                {
                    shouldShowCursor = false;
                }
                else if (KickStarter.playerInput.GetDragState() == DragState.Moveable)
                {
                    shouldShowCursor = false;
                }
                else if (KickStarter.settingsManager && KickStarter.cursorManager && (!KickStarter.cursorManager.allowMainCursor || KickStarter.cursorManager.pointerIcon.texture == null) && (KickStarter.runtimeInventory.SelectedItem == null || KickStarter.cursorManager.inventoryHandling == InventoryHandling.ChangeHotspotLabel) && KickStarter.settingsManager.inputMethod == InputMethod.MouseAndKeyboard && KickStarter.stateHandler.gameState != GameState.Cutscene)
                {
                    shouldShowCursor = true;
                }
                else if (KickStarter.cursorManager == null)
                {
                    shouldShowCursor = true;
                }
                else
                {
                    shouldShowCursor = false;
                }

                UnityVersionHandler.SetCursorVisibility(shouldShowCursor);
            }

            if (KickStarter.settingsManager && KickStarter.stateHandler)
            {
                if (forceOffCursor)
                {
                    showCursor = false;
                }
                else if (KickStarter.stateHandler.gameState == GameState.Cutscene)
                {
                    if (KickStarter.cursorManager.waitIcon.texture != null)
                    {
                        showCursor = true;
                    }
                    else
                    {
                        showCursor = false;
                    }
                }
                else if (KickStarter.stateHandler.gameState != GameState.Normal && KickStarter.settingsManager.inputMethod == InputMethod.KeyboardOrController)
                {
                    if (KickStarter.stateHandler.gameState == GameState.Paused && !KickStarter.menuManager.keyboardControlWhenPaused)
                    {
                        showCursor = true;
                    }
                    else if (KickStarter.stateHandler.gameState == GameState.DialogOptions && !KickStarter.menuManager.keyboardControlWhenDialogOptions)
                    {
                        showCursor = true;
                    }
                    else
                    {
                        showCursor = false;
                    }
                }
                else if (KickStarter.cursorManager)
                {
                    if (KickStarter.stateHandler.gameState == GameState.Paused && (KickStarter.cursorManager.cursorDisplay == CursorDisplay.OnlyWhenPaused || KickStarter.cursorManager.cursorDisplay == CursorDisplay.Always))
                    {
                        showCursor = true;
                    }
                    else if (KickStarter.playerInput.GetDragState() == DragState.Moveable)
                    {
                        showCursor = false;
                    }
                    else if (KickStarter.stateHandler.IsInGameplay() || KickStarter.stateHandler.gameState == GameState.DialogOptions)
                    {
                        showCursor = true;
                    }
                    else
                    {
                        showCursor = false;
                    }
                }
                else
                {
                    showCursor = true;
                }

                if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.CustomScript)
                {
                }

                else if (KickStarter.stateHandler.IsInGameplay() && KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot && KickStarter.cursorManager != null &&
                         ((KickStarter.cursorManager.cycleCursors && KickStarter.playerInput.GetMouseState() == MouseState.RightClick) || KickStarter.playerInput.InputGetButtonDown("CycleCursors")))
                {
                    CycleCursors();
                }

                else if (KickStarter.stateHandler.IsInGameplay() && KickStarter.settingsManager.SelectInteractionMethod() == SelectInteractions.CyclingCursorAndClickingHotspot &&
                         (KickStarter.playerInput.GetMouseState() == MouseState.RightClick || KickStarter.playerInput.InputGetButtonDown("CycleCursors")))
                {
                    KickStarter.playerInteraction.SetNextInteraction();
                }

                else if (KickStarter.stateHandler.IsInGameplay() && KickStarter.settingsManager.SelectInteractionMethod() == SelectInteractions.CyclingCursorAndClickingHotspot &&
                         (KickStarter.playerInput.InputGetButtonDown("CycleCursorsBack")))
                {
                    KickStarter.playerInteraction.SetPreviousInteraction();
                }

                else if (CanCycleContextSensitiveMode() && KickStarter.playerInput.GetMouseState() == MouseState.RightClick)
                {
                    Hotspot hotspot = KickStarter.playerInteraction.GetActiveHotspot();
                    if (hotspot != null)
                    {
                        if (hotspot.HasContextUse() && hotspot.HasContextLook())
                        {
                            KickStarter.playerInput.ResetMouseClick();
                            contextCycleExamine = !contextCycleExamine;
                        }
                    }
                    else if (KickStarter.runtimeInventory.hoverItem != null && KickStarter.runtimeInventory.SelectedItem == null)
                    {
                        if (KickStarter.runtimeInventory.hoverItem.lookActionList != null)
                        {
                            KickStarter.playerInput.ResetMouseClick();
                            contextCycleExamine = !contextCycleExamine;
                        }
                    }
                }
            }

            if (KickStarter.cursorManager.cursorRendering == CursorRendering.Hardware)
            {
                UnityVersionHandler.SetCursorVisibility(showCursor);
                DrawCursor();
            }
        }
Example #8
0
		protected void SharedGUI (DragBase _target, bool isOnHinge)
		{
			CustomGUILayout.BeginVertical ();
			EditorGUILayout.LabelField ("Collision settings:", EditorStyles.boldLabel);
			_target.ignorePlayerCollider = CustomGUILayout.ToggleLeft ("Ignore Player's collider?", _target.ignorePlayerCollider, "", "If True, then the Physics system will ignore collisions between this object and the player");
			_target.ignoreMoveableRigidbodies = CustomGUILayout.ToggleLeft ("Ignore Moveable Rigidbodies?", _target.ignoreMoveableRigidbodies, "", " If True, then the Physics system will ignore collisions between this object and the bounday colliders of any DragTrack that this is not locked to");
			_target.childrenShareLayer = CustomGUILayout.ToggleLeft ("Place children on same layer?", _target.childrenShareLayer, "", "If True, then this object's children will be placed on the same layer");

			EditorGUILayout.BeginHorizontal ();
			_target.interactiveBoundary = (InteractiveBoundary) CustomGUILayout.ObjectField <InteractiveBoundary> ("Interactive boundary:", _target.interactiveBoundary, true, "", "If assigned, then the draggable will only be interactive when the player is within this Trigger Collider's boundary");
			if (_target.interactiveBoundary == null)
			{
				if (GUILayout.Button ("Create", GUILayout.MaxWidth (90f)))
				{
					string prefabName = "InteractiveBoundary";
					if (SceneSettings.IsUnity2D ())
					{
						prefabName += "2D";
					}
					InteractiveBoundary newInteractiveBoundary = SceneManager.AddPrefab ("Logic", prefabName, true, false, true).GetComponent <InteractiveBoundary>();
					newInteractiveBoundary.gameObject.name += (": " + _target.gameObject.name);
					newInteractiveBoundary.transform.position = _target.transform.position;
					_target.interactiveBoundary = newInteractiveBoundary;

					UnityVersionHandler.PutInFolder (newInteractiveBoundary.gameObject, "_Hotspots");
				}
			}
			EditorGUILayout.EndHorizontal ();

			_target.limitToCamera = (_Camera) CustomGUILayout.ObjectField <_Camera> ("Limit to camera:", _target.limitToCamera, true, "", "If assigned, then the draggable  will only be interactive when the assigned _Camera is active");

			CustomGUILayout.EndVertical ();

			CustomGUILayout.BeginVertical ();
			EditorGUILayout.LabelField ("Icon settings:", EditorStyles.boldLabel);
			_target.showIcon = CustomGUILayout.Toggle ("Icon at contact point?", _target.showIcon, "", "If True, then an icon will be displayed at the 'grab point' when the object is held");
			if (_target.showIcon)
			{
				if (cursorManager && cursorManager.cursorIcons.Count > 0)
				{
					int cursorInt = cursorManager.GetIntFromID (_target.iconID);
					cursorInt = CustomGUILayout.Popup ("Cursor icon:", cursorInt, cursorManager.GetLabelsArray (), "", "The cursor that gets shown when held");
					_target.iconID = cursorManager.cursorIcons [cursorInt].id;
				}
				else
				{
					_target.iconID = -1;
				}
			}		
			CustomGUILayout.EndVertical ();

			CustomGUILayout.BeginVertical ();
			EditorGUILayout.LabelField ("Sound settings:", EditorStyles.boldLabel);
			_target.moveSoundClip = (AudioClip) CustomGUILayout.ObjectField <AudioClip> ("Move sound:", _target.moveSoundClip, false, "", "The sound to play when the object is moved");
			_target.slideSoundThreshold = CustomGUILayout.FloatField ("Min. move speed:", _target.slideSoundThreshold, "", "The minimum speed that the object must be moving by for sound to play");
			_target.slidePitchFactor = CustomGUILayout.FloatField ("Pitch factor:", _target.slidePitchFactor, "", "The factor by which the movement sound's pitch is adjusted in relation to speed");
		
			_target.collideSoundClip = (AudioClip) CustomGUILayout.ObjectField <AudioClip> ("Collide sound:", _target.collideSoundClip, false, "", "The sound to play when the object has a collision");
			if (isOnHinge)
			{
				_target.onlyPlayLowerCollisionSound = CustomGUILayout.Toggle ("Only on lower boundary?", _target.onlyPlayLowerCollisionSound, "", "If True, then the collision sound will only play when the object collides with its lower boundary collider");
			}
			CustomGUILayout.EndVertical ();
		}
Example #9
0
        private void ShowPropertiesGUI(ActionList _target)
        {
            CustomGUILayout.BeginVertical();
            EditorGUILayout.LabelField("ActionList properties", EditorStyles.boldLabel);
            _target.source = (ActionListSource)CustomGUILayout.EnumPopup("Actions source:", _target.source, "", "Where the Actions are stored");
            if (_target.source == ActionListSource.AssetFile)
            {
                _target.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList asset:", _target.assetFile, false, "", "The ActionList asset that stores the Actions");
                if (_target.assetFile && _target.assetFile.NumParameters > 0)
                {
                    _target.syncParamValues = CustomGUILayout.Toggle("Sync parameter values?", _target.syncParamValues, "", "If True, the ActionList asset's parameter values will be shared amongst all linked ActionLists");
                }
            }
            _target.actionListType = (ActionListType)CustomGUILayout.EnumPopup("When running:", _target.actionListType, "", "The effect that running the Actions has on the rest of the game");
            if (_target.actionListType == ActionListType.PauseGameplay)
            {
                _target.isSkippable = CustomGUILayout.Toggle("Is skippable?", _target.isSkippable, "", "If True, the Actions will be skipped when the user presses the 'EndCutscene' Input button");
            }
            _target.tagID = ShowTagUI(_target.actions.ToArray(), _target.tagID);
            if (_target.source == ActionListSource.InScene)
            {
                _target.useParameters = CustomGUILayout.Toggle("Use parameters?", _target.useParameters, "", "If True, ActionParameters can be used to override values within the Action objects");
            }
            else if (_target.source == ActionListSource.AssetFile && _target.assetFile && !_target.syncParamValues && _target.assetFile.useParameters && !Application.isPlaying)
            {
                _target.useParameters = CustomGUILayout.Toggle("Set local parameter values?", _target.useParameters, "", "If True, parameter values set here will be assigned locally, and not on the ActionList asset");
            }
            CustomGUILayout.EndVertical();

            if (_target.source == ActionListSource.InScene)
            {
                EditorGUILayout.Space();
                CustomGUILayout.BeginVertical();

                EditorGUILayout.LabelField("Parameters", EditorStyles.boldLabel);
                ShowParametersGUI(_target, null, _target.parameters);

                CustomGUILayout.EndVertical();
            }
            else if (_target.source == ActionListSource.AssetFile && _target.assetFile && _target.assetFile.useParameters)
            {
                if (_target.syncParamValues)
                {
                    EditorGUILayout.Space();
                    CustomGUILayout.BeginVertical();
                    EditorGUILayout.LabelField("Parameters", EditorStyles.boldLabel);
                    ShowParametersGUI(null, _target.assetFile, _target.assetFile.GetParameters(), !Application.isPlaying);
                    CustomGUILayout.EndVertical();
                }
                else
                {
                    if (_target.useParameters)
                    {
                        bool isAsset = UnityVersionHandler.IsPrefabFile(_target.gameObject);

                        EditorGUILayout.Space();
                        CustomGUILayout.BeginVertical();

                        EditorGUILayout.LabelField("Local parameters", EditorStyles.boldLabel);
                        ShowLocalParametersGUI(_target.parameters, _target.assetFile.GetParameters(), isAsset);

                        CustomGUILayout.EndVertical();
                    }
                    else
                    {
                        // Use default from asset initially

                        EditorGUILayout.Space();
                        CustomGUILayout.BeginVertical();
                        EditorGUILayout.LabelField("Parameters", EditorStyles.boldLabel);
                        if (Application.isPlaying)
                        {
                            ShowParametersGUI(_target, null, _target.parameters);
                        }
                        else
                        {
                            ShowParametersGUI(null, _target.assetFile, _target.assetFile.DefaultParameters, true);
                        }
                        CustomGUILayout.EndVertical();
                    }
                }
            }
        }
        private void OnGUI()
        {
            GUILayout.BeginVertical(CustomStyles.thinBox, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));

            GUILayout.Label(GetTitle(), CustomStyles.managerHeader);
            if (GetTitle() != "")
            {
                EditorGUILayout.Separator();
                GUILayout.Space(10f);
            }

            ShowPage();

            GUILayout.Space(15f);
            GUILayout.BeginHorizontal();
            if (pageNumber < 1)
            {
                if (pageNumber < 0)
                {
                    pageNumber = 0;
                }
                GUI.enabled = false;
            }
            if (pageNumber < numPages)
            {
                if (GUILayout.Button("Previous", EditorStyles.miniButtonLeft))
                {
                    pageNumber--;
                }
            }
            else
            {
                if (GUILayout.Button("Restart", EditorStyles.miniButtonLeft))
                {
                    pageNumber = 0;
                }
            }

            GUI.enabled = true;
            if (pageNumber < numPages - 1)
            {
                if (pageNumber == 1)
                {
                    if (!IsFirstPerson())
                    {
                        if (baseObject == null || UnityVersionHandler.IsPrefabFile(baseObject) || baseObject.GetComponent <AC.Char>() || !baseObject.activeInHierarchy)
                        {
                            GUI.enabled = false;
                        }
                    }
                }

                if (GUILayout.Button("Next", EditorStyles.miniButtonRight))
                {
                    pageNumber++;
                    if (pageNumber == 2 && IsFirstPerson())
                    {
                        animationEngine = AnimationEngine.Mecanim;
                        pageNumber      = 3;
                    }
                    if (pageNumber == 2)
                    {
                        if (baseObject != null && baseObject.GetComponentInChildren <Animation>())
                        {
                            animationEngine = AnimationEngine.Legacy;
                        }
                        else if (baseObject != null && (baseObject.GetComponentInChildren <SkinnedMeshRenderer>() || baseObject.GetComponentInChildren <MeshRenderer>()))
                        {
                            animationEngine = AnimationEngine.Mecanim;
                        }
                        else if (baseObject != null && baseObject.GetComponentInChildren <SpriteRenderer>())
                        {
                            animationEngine = AnimationEngine.SpritesUnity;
                        }
                        else if (baseObject != null && tk2DIntegration.Is2DtkSprite(baseObject))
                        {
                            animationEngine = AnimationEngine.Sprites2DToolkit;
                        }
                        else if (SceneSettings.CameraPerspective == CameraPerspective.TwoD)
                        {
                            animationEngine = AnimationEngine.SpritesUnity;
                        }
                        else
                        {
                            animationEngine = AnimationEngine.Mecanim;
                        }
                    }
                }

                GUI.enabled = true;
            }
            else
            {
                if (pageNumber == numPages)
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Button("Finish", EditorStyles.miniButtonRight))
                {
                    pageNumber++;
                    Finish();
                }
                GUI.enabled = true;
            }
            GUILayout.EndHorizontal();

            GUI.Label(pageRect, "Page " + (pageNumber + 1) + " of " + (numPages + 1));

            GUILayout.FlexibleSpace();
            CustomGUILayout.EndVertical();
        }
Example #11
0
        public void ShowGUI()
        {
            EditorGUILayout.BeginVertical("Button");

            saveController = EditorGUILayout.ToggleLeft("Save change in Controller?", saveController);

            setDefaultParameterValues = EditorGUILayout.ToggleLeft("Set default parameters?", setDefaultParameterValues);
            if (setDefaultParameterValues)
            {
                if (!UnityVersionHandler.IsPrefabEditing(gameObject) && !UnityVersionHandler.ObjectIsInActiveScene(gameObject))
                {
                    EditorGUILayout.HelpBox("To view/edit parameters, the GameObject must be active in the scene.", MessageType.Warning);
                }
                else if (Animator.parameters != null)
                {
                    GUILayout.Box(string.Empty, GUILayout.ExpandWidth(true), GUILayout.Height(1));

                    int numParameters = Animator.parameters.Length;
                    if (numParameters < defaultAnimParameters.Count)
                    {
                        defaultAnimParameters.RemoveRange(numParameters, defaultAnimParameters.Count - numParameters);
                    }
                    else if (numParameters > defaultAnimParameters.Count)
                    {
                        if (numParameters > defaultAnimParameters.Capacity)
                        {
                            defaultAnimParameters.Capacity = numParameters;
                        }
                        for (int i = defaultAnimParameters.Count; i < numParameters; i++)
                        {
                            defaultAnimParameters.Add(new DefaultAnimParameter());
                        }
                    }

                    for (int i = 0; i < Animator.parameters.Length; i++)
                    {
                        AnimatorControllerParameter parameter = Animator.parameters[i];
                        switch (parameter.type)
                        {
                        case AnimatorControllerParameterType.Bool:
                            bool boolValue = (defaultAnimParameters[i].intValue == 1);
                            boolValue = EditorGUILayout.Toggle(parameter.name, boolValue);
                            defaultAnimParameters[i] = new DefaultAnimParameter((boolValue) ? 1 : 0);
                            break;

                        case AnimatorControllerParameterType.Float:
                            float floatValue = EditorGUILayout.FloatField(parameter.name, defaultAnimParameters[i].floatValue);
                            defaultAnimParameters[i] = new DefaultAnimParameter(floatValue);
                            break;

                        case AnimatorControllerParameterType.Int:
                            int intValue = EditorGUILayout.IntField(parameter.name, defaultAnimParameters[i].intValue);
                            defaultAnimParameters[i] = new DefaultAnimParameter(intValue);
                            break;
                        }
                    }
                }
            }

            EditorGUILayout.EndVertical();
        }
        private void ShowPage()
        {
            GUI.skin.label.wordWrap = true;

            if (pageNumber == 0)
            {
                if (Resource.ACLogo != null)
                {
                    GUI.DrawTexture(new Rect(82, 25, 256, 128), Resource.ACLogo);
                }
                GUILayout.Space(140f);
                GUILayout.Label("This window can assist with the creation of a Player or NPC.");
                GUILayout.Label("To begin, click 'Next'.");
            }

            else if (pageNumber == 1)
            {
                GUILayout.Label("Is this a Player or an NPC?");
                charType = (CharType)EditorGUILayout.EnumPopup(charType);

                if (charType == CharType.NPC)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label("The character's name:", GUILayout.Width(150f));
                    charName = GUILayout.TextField(charName);
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    if (AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.movementMethod == MovementMethod.FirstPerson)
                    {
                        EditorGUILayout.HelpBox("First-person Player prefabs require no base graphic, though one can be added after creation if desired.", MessageType.Info);
                        return;
                    }
                }

                GUILayout.Label("Assign your character's base GameObject (such as a Skinned Mesh Renderer or 'idle' sprite):");
                baseObject = (GameObject)EditorGUILayout.ObjectField(baseObject, typeof(GameObject), true);

                if (baseObject != null && !IsFirstPerson())
                {
                    if (baseObject.GetComponent <AC.Char>())
                    {
                        EditorGUILayout.HelpBox("The wizard cannot modify an existing character!", MessageType.Warning);
                    }
                    else if (UnityVersionHandler.IsPrefabFile(baseObject) || !baseObject.activeInHierarchy)
                    {
                        EditorGUILayout.HelpBox("The object must be in the scene and enabled for the wizard to work.", MessageType.Warning);
                    }
                }
            }

            else if (pageNumber == 2)
            {
                GUILayout.Label("How should '" + charType.ToString() + "' should be animated?");
                animationEngine = (AnimationEngine)EditorGUILayout.EnumPopup(animationEngine);

                if (animationEngine == AnimationEngine.Custom)
                {
                    EditorGUILayout.HelpBox("This option is intended for characters that make use of a custom/third-party animation system that will require additional coding.", MessageType.Info);
                }
                else if (animationEngine == AnimationEngine.Legacy)
                {
                    EditorGUILayout.HelpBox("Legacy animation is for 3D characters that do not require complex animation trees or multiple layers. Its easier to use than Mecanim, but not as powerful.", MessageType.Info);
                }
                else if (animationEngine == AnimationEngine.Mecanim)
                {
                    EditorGUILayout.HelpBox("Mecanim animation is the standard option for 3D characters. You will need to define Mecanim parameters and transitions, but will have full control over how the character is animated.", MessageType.Info);
                }
                else if (animationEngine == AnimationEngine.Sprites2DToolkit)
                {
                    EditorGUILayout.HelpBox("This option allows you to animate characters using the 3rd-party 2D Toolkit asset.", MessageType.Info);
                    if (!tk2DIntegration.IsDefinePresent())
                    {
                        EditorGUILayout.HelpBox("The 'tk2DIsPresent' preprocessor define must be declared in your game's Scripting Define Symbols, found in File -> Build -> Player settings.", MessageType.Warning);
                    }
                }
                else if (animationEngine == AnimationEngine.SpritesUnity)
                {
                    EditorGUILayout.HelpBox("This option is the standard option for 2D characters. Animation clips are played automatically, without the need to define Mecanim parameters, but you will not be able to make e.g. smooth transitions between the different movement animations.", MessageType.Info);
                }
                else if (animationEngine == AnimationEngine.SpritesUnityComplex)
                {
                    EditorGUILayout.HelpBox("This option is harder to use than 'Sprites Unity', but gives you more control over how your character animates - allowing you to control animations using Mecanim parameters and transitions.", MessageType.Info);
                }
            }

            else if (pageNumber == 3)
            {
                EditorGUILayout.LabelField("Chosen animation engine: " + animationEngine.ToString(), EditorStyles.boldLabel);

                if (!IsFirstPerson())
                {
                    if (animationEngine == AnimationEngine.Custom)
                    {
                        EditorGUILayout.HelpBox("A subclass of 'AnimEngine' will be used to bridge AC with an external animation engine. The subclass script defined above must exist for the character to animate. Once created, enter its name in the box below:", MessageType.Info);
                        customAnimationClass = EditorGUILayout.TextField("Subclass script name:", customAnimationClass);
                    }
                    else if (animationEngine == AnimationEngine.Mecanim || animationEngine == AnimationEngine.SpritesUnityComplex || animationEngine == AnimationEngine.SpritesUnity)
                    {
                        if (baseObject.GetComponent <Animator>() == null)
                        {
                            EditorGUILayout.HelpBox("This chosen method will make use of an Animator Controller asset.\nOnce the wizard has finished, you will need to create such an asset and assign it in your character's 'Animator' component.", MessageType.Info);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("This chosen method will make use of an Animator component, and one has already been detected on the base object.\nThis will be assumed to be the Animator to animate the character with.", MessageType.Info);
                        }
                    }

                    if (animationEngine == AnimationEngine.Sprites2DToolkit || animationEngine == AnimationEngine.SpritesUnityComplex || animationEngine == AnimationEngine.SpritesUnity)
                    {
                        if (SceneSettings.CameraPerspective != CameraPerspective.TwoD)
                        {
                            EditorGUILayout.LabelField("It has been detected that you are attempting\nto create a 2D character in a 3D game.\nIs this correct?", GUILayout.Height(40f));
                            enforce3D = EditorGUILayout.Toggle("Yes!", enforce3D);
                        }
                    }
                }
                EditorGUILayout.HelpBox("Click 'Finish' below to create the character and complete the wizard.", MessageType.Info);
            }

            else if (pageNumber == 4)
            {
                GUILayout.Label("Congratulations, your " + charType.ToString() + " has been created! Check the '" + charType.ToString() + "' Inspector to set up animation and other properties, as well as modify any generated Colliders / Rigidbody components.");
                if (charType == CharType.Player)
                {
                    GUILayout.Space(5f);
                    GUILayout.Label("To register this is as the main player character, turn it into a prefab and assign it in your Settings Manager, underneath 'Player settings'.");
                }
            }
        }
Example #13
0
        /**
         * <summary>Adds a ConstantID component to a GameObject, which can be a prefab or a scene-based object</summary>
         * <param name = "gameObject">The GameObject to amend</param>
         * <returns>The GameObject's component</returns>
         */
        public static T AddConstantIDToGameObject <T> (GameObject gameObject, bool forcePrefab = false) where T : ConstantID
        {
            T existingComponent = gameObject.GetComponent <T>();

            if (existingComponent != null)
            {
                if (existingComponent.constantID == 0)
                {
                                        #if NEW_PREFABS
                    if (IsPrefabFile(gameObject) && !IsPrefabEditing(gameObject))
                    {
                        string     assetPath       = AssetDatabase.GetAssetPath(gameObject);
                        GameObject instancedObject = PrefabUtility.LoadPrefabContents(assetPath);
                        instancedObject.GetComponent <ConstantID>().AssignInitialValue(true);
                        PrefabUtility.SaveAsPrefabAsset(instancedObject, assetPath);
                        PrefabUtility.UnloadPrefabContents(instancedObject);
                    }
                    else
                    {
                        existingComponent.AssignInitialValue(forcePrefab);
                    }
                                        #else
                    existingComponent.AssignInitialValue(forcePrefab);
                                        #endif
                }

                CustomSetDirty(gameObject, true);
                if (IsPrefabFile(gameObject))
                {
                    AssetDatabase.SaveAssets();
                }

                return(existingComponent);
            }

                        #if NEW_PREFABS
            if (UnityVersionHandler.IsPrefabFile(gameObject) && !IsPrefabEditing(gameObject))
            {
                string     assetPath       = AssetDatabase.GetAssetPath(gameObject);
                GameObject instancedObject = PrefabUtility.LoadPrefabContents(assetPath);
                existingComponent = instancedObject.AddComponent <T>();
                existingComponent.AssignInitialValue(true);

                foreach (ConstantID constantIDScript in instancedObject.GetComponents <ConstantID>())
                {
                    if (!(constantIDScript is Remember) && !(constantIDScript is RememberTransform) && constantIDScript != existingComponent)
                    {
                        GameObject.DestroyImmediate(constantIDScript, true);
                        ACDebug.Log("Replaced " + gameObject.name + "'s 'ConstantID' component with '" + existingComponent.GetType().ToString() + "'", gameObject);
                    }
                }

                PrefabUtility.SaveAsPrefabAsset(instancedObject, assetPath);
                PrefabUtility.UnloadPrefabContents(instancedObject);

                CustomSetDirty(gameObject, true);
                AssetDatabase.SaveAssets();

                return(existingComponent);
            }
                        #endif

            existingComponent = gameObject.AddComponent <T>();
            existingComponent.AssignInitialValue(forcePrefab);

            foreach (ConstantID constantIDScript in gameObject.GetComponents <ConstantID>())
            {
                if (!(constantIDScript is Remember) && !(constantIDScript is RememberTransform) && constantIDScript != existingComponent)
                {
                    GameObject.DestroyImmediate(constantIDScript, true);
                    ACDebug.Log("Replaced " + gameObject.name + "'s 'ConstantID' component with '" + existingComponent.GetType().ToString() + "'", gameObject);
                }
            }

            CustomSetDirty(gameObject, true);
            if (IsPrefabFile(gameObject))
            {
                AssetDatabase.SaveAssets();
            }

            return(existingComponent);
        }
Example #14
0
        public override void OnInspectorGUI()
        {
            Moveable_Drag _target = (Moveable_Drag)target;

            GetReferences();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Movment settings:", EditorStyles.boldLabel);
            _target.maxSpeed = EditorGUILayout.FloatField("Max speed:", _target.maxSpeed);
            _target.playerMovementReductionFactor = EditorGUILayout.Slider("Player movement reduction:", _target.playerMovementReductionFactor, 0f, 1f);
            _target.playerMovementInfluence       = EditorGUILayout.FloatField("Player movement influence:", _target.playerMovementInfluence);
            _target.invertInput = EditorGUILayout.Toggle("Invert input?", _target.invertInput);
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Button");

            EditorGUILayout.LabelField("Drag settings:", EditorStyles.boldLabel);
            _target.dragMode = (DragMode)EditorGUILayout.EnumPopup("Drag mode:", _target.dragMode);
            if (_target.dragMode == DragMode.LockToTrack)
            {
                _target.track = (DragTrack)EditorGUILayout.ObjectField("Track to stick to:", _target.track, typeof(DragTrack), true);

                if (_target.track != null && _target.track is DragTrack_Straight)
                {
                    EditorGUILayout.HelpBox("For best results, ensure the first collider on this GameObject is a Sphere Collider covering the breath of the mesh.\r\nIt can be disabled if necessary, but will be used to set correct limit boundaries.", MessageType.Info);
                }

                _target.setOnStart = EditorGUILayout.Toggle("Set starting position?", _target.setOnStart);
                if (_target.setOnStart)
                {
                    _target.trackValueOnStart = EditorGUILayout.Slider("Initial distance along:", _target.trackValueOnStart, 0f, 1f);
                }
                _target.retainOriginalTransform = EditorGUILayout.ToggleLeft("Maintain original child transforms?", _target.retainOriginalTransform);

                EditorGUILayout.BeginHorizontal();
                _target.interactionOnMove = (Interaction)EditorGUILayout.ObjectField("Interaction on move:", _target.interactionOnMove, typeof(Interaction), true);

                if (_target.interactionOnMove == null)
                {
                    if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                    {
                        Undo.RecordObject(_target, "Create Interaction");
                        Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>();
                        newInteraction.gameObject.name = AdvGame.UniqueName("Move : " + _target.gameObject.name);
                        _target.interactionOnMove      = newInteraction;
                    }
                }
                EditorGUILayout.EndVertical();
            }
            else if (_target.dragMode == DragMode.MoveAlongPlane)
            {
                _target.alignMovement = (AlignDragMovement)EditorGUILayout.EnumPopup("Align movement:", _target.alignMovement);
                if (_target.alignMovement == AlignDragMovement.AlignToPlane)
                {
                    _target.plane = (Transform)EditorGUILayout.ObjectField("Movement plane:", _target.plane, typeof(Transform), true);
                }
            }
            else if (_target.dragMode == DragMode.RotateOnly)
            {
                _target.rotationFactor = EditorGUILayout.FloatField("Rotation factor:", _target.rotationFactor);
                _target.allowZooming   = EditorGUILayout.Toggle("Allow zooming?", _target.allowZooming);
                if (_target.allowZooming)
                {
                    _target.zoomSpeed = EditorGUILayout.FloatField("Zoom speed:", _target.zoomSpeed);
                    _target.minZoom   = EditorGUILayout.FloatField("Closest distance:", _target.minZoom);
                    _target.maxZoom   = EditorGUILayout.FloatField("Farthest distance:", _target.maxZoom);
                }
            }

            if (_target.dragMode != DragMode.LockToTrack)
            {
                _target.noGravityWhenHeld = EditorGUILayout.Toggle("Disable gravity when held?", _target.noGravityWhenHeld);
            }

            if (Application.isPlaying && _target.dragMode == DragMode.LockToTrack && _target.track)
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Distance along: " + _target.GetPositionAlong().ToString(), EditorStyles.miniLabel);
            }

            EditorGUILayout.EndVertical();

            if (_target.dragMode == DragMode.LockToTrack && _target.track is DragTrack_Hinge)
            {
                SharedGUI(_target, true);
            }
            else
            {
                SharedGUI(_target, false);
            }

            DisplayInputList(_target);

            UnityVersionHandler.CustomSetDirty(_target);
        }
Example #15
0
 private void AssignThisSceneInfo()
 {
     thisSceneInfo = new SceneInfo(UnityVersionHandler.GetCurrentSceneName(), UnityVersionHandler.GetCurrentSceneNumber());
 }
        /**
         * Assigns its various Manager asset files.
         */
        public void AssignManagers()
        {
            if (AdvGame.GetReferences() != null)
            {
                int numAssigned = 0;

                if (sceneManager)
                {
                    AdvGame.GetReferences().sceneManager = sceneManager;
                    numAssigned++;
                }

                if (settingsManager)
                {
                    AdvGame.GetReferences().settingsManager = settingsManager;
                    numAssigned++;
                }

                if (actionsManager)
                {
                    AdvGame.GetReferences().actionsManager = actionsManager;
                    numAssigned++;
                }

                if (variablesManager)
                {
                    AdvGame.GetReferences().variablesManager = variablesManager;
                    numAssigned++;
                }

                if (inventoryManager)
                {
                    AdvGame.GetReferences().inventoryManager = inventoryManager;
                    numAssigned++;
                }

                if (speechManager)
                {
                    AdvGame.GetReferences().speechManager = speechManager;
                    numAssigned++;
                }

                if (cursorManager)
                {
                    AdvGame.GetReferences().cursorManager = cursorManager;
                    numAssigned++;
                }

                if (menuManager)
                {
                    AdvGame.GetReferences().menuManager = menuManager;
                    numAssigned++;
                }

                                #if UNITY_EDITOR
                if (KickStarter.sceneManager)
                {
                    KickStarter.sceneManager.GetPrefabsInScene();
                }

                UnityVersionHandler.CustomSetDirty(AdvGame.GetReferences(), true);
                AssetDatabase.SaveAssets();
                                #endif

                if (this)
                {
                    if (numAssigned == 0)
                    {
                        ACDebug.Log(this.name + " No Mangers assigned.");
                    }
                    else if (numAssigned == 1)
                    {
                        ACDebug.Log(this.name + " - (" + numAssigned.ToString() + ") Manager assigned.");
                    }
                    else
                    {
                        ACDebug.Log(this.name + " - (" + numAssigned.ToString() + ") Managers assigned.");
                    }
                }
            }
            else
            {
                ACDebug.LogError("Can't assign managers - no References file found in Resources folder.");
            }
        }
Example #17
0
 /**
  * A Constructor for the current active scene.
  */
 public SceneInfo()
 {
     number = UnityVersionHandler.GetCurrentSceneNumber();
     name   = UnityVersionHandler.GetCurrentSceneName();
 }
        /**
         * Updates the cursor. This is called every frame by StateHandler.
         */
        public void UpdateCursor()
        {
            if (KickStarter.cursorManager.cursorRendering == CursorRendering.Software)
            {
                bool shouldShowCursor = false;

                if (!canShowHardwareCursor)
                {
                    shouldShowCursor = false;
                }
                else if (KickStarter.playerInput.GetDragState() == DragState.Moveable)
                {
                    shouldShowCursor = false;
                }
                else if (KickStarter.settingsManager && KickStarter.cursorManager && (!KickStarter.cursorManager.allowMainCursor || KickStarter.cursorManager.pointerIcon.texture == null) && (KickStarter.runtimeInventory.selectedItem == null || KickStarter.cursorManager.inventoryHandling == InventoryHandling.ChangeHotspotLabel) && KickStarter.settingsManager.inputMethod == InputMethod.MouseAndKeyboard && KickStarter.stateHandler.gameState != GameState.Cutscene)
                {
                    shouldShowCursor = true;
                }
                else if (KickStarter.cursorManager == null)
                {
                    shouldShowCursor = true;
                }
                else
                {
                    shouldShowCursor = false;
                }

                UnityVersionHandler.SetCursorVisibility(shouldShowCursor);
            }

            if (KickStarter.settingsManager && KickStarter.stateHandler)
            {
                if (KickStarter.stateHandler.gameState == GameState.Cutscene)
                {
                    if (KickStarter.cursorManager.waitIcon.texture != null)
                    {
                        showCursor = true;
                    }
                    else
                    {
                        showCursor = false;
                    }
                }
                else if (KickStarter.stateHandler.gameState != GameState.Normal && KickStarter.settingsManager.inputMethod == InputMethod.KeyboardOrController)
                {
                    showCursor = false;
                }
                else if (KickStarter.cursorManager)
                {
                    if (KickStarter.stateHandler.gameState == GameState.Paused && (KickStarter.cursorManager.cursorDisplay == CursorDisplay.OnlyWhenPaused || KickStarter.cursorManager.cursorDisplay == CursorDisplay.Always))
                    {
                        showCursor = true;
                    }
                    else if (KickStarter.playerInput.GetDragState() == DragState.Moveable)
                    {
                        showCursor = false;
                    }
                    //else if ((KickStarter.stateHandler.gameState == GameState.Normal || KickStarter.stateHandler.gameState == GameState.DialogOptions) && (KickStarter.cursorManager.cursorDisplay == CursorDisplay.Always))
                    else if (KickStarter.stateHandler.gameState == GameState.Normal || KickStarter.stateHandler.gameState == GameState.DialogOptions)
                    {
                        showCursor = true;
                    }
                    else
                    {
                        showCursor = false;
                    }
                }
                else
                {
                    showCursor = true;
                }

                if (KickStarter.stateHandler.gameState == GameState.Normal && KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot && KickStarter.cursorManager != null &&
                    ((KickStarter.cursorManager.cycleCursors && KickStarter.playerInput.GetMouseState() == MouseState.RightClick) || KickStarter.playerInput.InputGetButtonDown("CycleCursors")))
                {
                    CycleCursors();
                }

                else if (KickStarter.stateHandler.gameState == GameState.Normal && KickStarter.settingsManager.SelectInteractionMethod() == SelectInteractions.CyclingCursorAndClickingHotspot &&
                         (KickStarter.playerInput.GetMouseState() == MouseState.RightClick || KickStarter.playerInput.InputGetButtonDown("CycleCursors")))
                {
                    KickStarter.playerInteraction.SetNextInteraction();
                }

                else if (KickStarter.stateHandler.gameState == GameState.Normal && KickStarter.settingsManager.SelectInteractionMethod() == SelectInteractions.CyclingCursorAndClickingHotspot &&
                         (KickStarter.playerInput.InputGetButtonDown("CycleCursorsBack")))
                {
                    KickStarter.playerInteraction.SetPreviousInteraction();
                }
            }

            if (KickStarter.cursorManager.cursorRendering == CursorRendering.Hardware)
            {
                UnityVersionHandler.SetCursorVisibility(showCursor);
            }

            if (KickStarter.cursorManager.cursorRendering == CursorRendering.Hardware)
            {
                DrawCursor();
            }
        }
Example #19
0
        public override void OnInspectorGUI()
        {
            if (AdvGame.GetReferences() == null)
            {
                ACDebug.LogError("A References file is required - please use the Adventure Creator window to create one.");
                EditorGUILayout.LabelField("No References file found!");
            }
            else
            {
                if (AdvGame.GetReferences().inventoryManager)
                {
                    inventoryManager = AdvGame.GetReferences().inventoryManager;
                }
                if (AdvGame.GetReferences().cursorManager)
                {
                    cursorManager = AdvGame.GetReferences().cursorManager;
                }
                if (AdvGame.GetReferences().settingsManager)
                {
                    settingsManager = AdvGame.GetReferences().settingsManager;
                }

                if (Application.isPlaying)
                {
                    if (_target.gameObject.layer != LayerMask.NameToLayer(settingsManager.hotspotLayer))
                    {
                        EditorGUILayout.HelpBox("Current state: OFF", MessageType.Info);
                    }
                }

                if (_target.lineID > -1)
                {
                    EditorGUILayout.LabelField("Speech Manager ID:", _target.lineID.ToString());
                }

                _target.interactionSource = (InteractionSource)EditorGUILayout.EnumPopup("Interaction source:", _target.interactionSource);
                _target.hotspotName       = EditorGUILayout.TextField("Label (if not name):", _target.hotspotName);
                _target.highlight         = (Highlight)EditorGUILayout.ObjectField("Object to highlight:", _target.highlight, typeof(Highlight), true);
                if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.hotspotDrawing == ScreenWorld.WorldSpace)
                {
                    _target.iconSortingLayer = EditorGUILayout.TextField("Icon sorting layer:", _target.iconSortingLayer);
                    _target.iconSortingOrder = EditorGUILayout.IntField("Icon sprite order:", _target.iconSortingOrder);
                }

                EditorGUILayout.BeginHorizontal();
                _target.centrePoint = (Transform)EditorGUILayout.ObjectField("Centre point (override):", _target.centrePoint, typeof(Transform), true);

                if (_target.centrePoint == null)
                {
                    if (GUILayout.Button("Create", autoWidth))
                    {
                        string     prefabName = "Hotspot centre: " + _target.gameObject.name;
                        GameObject go         = SceneManager.AddPrefab("Navigation", "HotspotCentre", true, false, false);
                        go.name = prefabName;
                        go.transform.position = _target.transform.position;
                        _target.centrePoint   = go.transform;
                        if (GameObject.Find("_Markers"))
                        {
                            go.transform.parent = GameObject.Find("_Markers").transform;
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                _target.walkToMarker = (Marker)EditorGUILayout.ObjectField("Walk-to marker:", _target.walkToMarker, typeof(Marker), true);

                if (_target.walkToMarker == null)
                {
                    if (GUILayout.Button("Create", autoWidth))
                    {
                        string prefabName = "Marker";
                        if (settingsManager && settingsManager.IsUnity2D())
                        {
                            prefabName += "2D";
                        }
                        Marker newMarker = SceneManager.AddPrefab("Navigation", prefabName, true, false, true).GetComponent <Marker>();
                        newMarker.gameObject.name   += (": " + _target.gameObject.name);
                        newMarker.transform.position = _target.transform.position;
                        _target.walkToMarker         = newMarker;
                    }
                }
                EditorGUILayout.EndHorizontal();

                _target.limitToCamera = (_Camera)EditorGUILayout.ObjectField("Limit to camera:", _target.limitToCamera, typeof(_Camera), true);
                _target.drawGizmos    = EditorGUILayout.Toggle("Draw yellow cube?", _target.drawGizmos);

                if (settingsManager != null && settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive)
                {
                    _target.oneClick = EditorGUILayout.Toggle("Single 'Use' Interaction?", _target.oneClick);
                }
                if (_target.oneClick || (settingsManager != null && settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive))
                {
                    _target.doubleClickingHotspot = (DoubleClickingHotspot)EditorGUILayout.EnumPopup("Double-clicking:", _target.doubleClickingHotspot);
                }
                if (settingsManager != null && settingsManager.playerFacesHotspots)
                {
                    _target.playerTurnsHead = EditorGUILayout.Toggle("Turn head active?", _target.playerTurnsHead);
                }

                EditorGUILayout.Space();

                UseInteractionGUI();

                if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
                {
                    EditorGUILayout.Space();
                    LookInteractionGUI();
                }

                EditorGUILayout.Space();
                InvInteractionGUI();

                EditorGUILayout.Space();
                UnhandledInvInteractionGUI();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
Example #20
0
        public static void ShowLocalParametersGUI(List <ActionParameter> localParameters, List <ActionParameter> assetParameters, bool isAssetFile)
        {
            int numParameters = assetParameters.Count;

            if (numParameters < localParameters.Count)
            {
                localParameters.RemoveRange(numParameters, localParameters.Count - numParameters);
            }
            else if (numParameters > localParameters.Count)
            {
                if (numParameters > localParameters.Capacity)
                {
                    localParameters.Capacity = numParameters;
                }
                for (int i = localParameters.Count; i < numParameters; i++)
                {
                    ActionParameter newParameter = new ActionParameter(ActionListEditor.GetParameterIDArray(localParameters));
                    localParameters.Add(newParameter);
                }
            }

            for (int i = 0; i < numParameters; i++)
            {
                string label = assetParameters[i].label;
                localParameters[i].parameterType = assetParameters[i].parameterType;

                if (Application.isPlaying)
                {
                    EditorGUILayout.LabelField(assetParameters[i].ID.ToString() + ": " + localParameters[i].parameterType.ToString() + " '" + label + "'");
                    EditorGUILayout.LabelField("Current value: '" + localParameters[i].GetLabel() + "'");
                }
                else
                {
                    if (assetParameters[i].parameterType == ParameterType.String)
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField(label + ":", GUILayout.Width(145f));
                        EditorStyles.textField.wordWrap = true;
                        localParameters[i].stringValue  = EditorGUILayout.TextArea(localParameters[i].stringValue, GUILayout.MaxWidth(400f));
                        EditorGUILayout.EndHorizontal();
                    }
                    else if (assetParameters[i].parameterType == ParameterType.Float)
                    {
                        localParameters[i].floatValue = EditorGUILayout.FloatField(label + ":", localParameters[i].floatValue);
                    }
                    else if (assetParameters[i].parameterType == ParameterType.Integer)
                    {
                        localParameters[i].intValue = EditorGUILayout.IntField(label + ":", localParameters[i].intValue);
                    }
                    else if (assetParameters[i].parameterType == ParameterType.Boolean)
                    {
                        BoolValue boolValue = BoolValue.False;
                        if (localParameters[i].intValue == 1)
                        {
                            boolValue = BoolValue.True;
                        }

                        boolValue = (BoolValue)EditorGUILayout.EnumPopup(label + ":", boolValue);

                        if (boolValue == BoolValue.True)
                        {
                            localParameters[i].intValue = 1;
                        }
                        else
                        {
                            localParameters[i].intValue = 0;
                        }
                    }
                    else if (assetParameters[i].parameterType == ParameterType.GlobalVariable)
                    {
                        if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager)
                        {
                            VariablesManager variablesManager = AdvGame.GetReferences().variablesManager;
                            localParameters[i].intValue = ActionRunActionList.ShowVarSelectorGUI(label + ":", variablesManager.vars, localParameters[i].intValue);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("A Variables Manager is required to pass Global Variables.", MessageType.Warning);
                        }
                    }
                    else if (assetParameters[i].parameterType == ParameterType.InventoryItem)
                    {
                        if (AdvGame.GetReferences() && AdvGame.GetReferences().inventoryManager)
                        {
                            InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager;
                            localParameters[i].intValue = ActionRunActionList.ShowInvItemSelectorGUI(label + ":", inventoryManager.items, localParameters[i].intValue);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("An Inventory Manager is required to pass Inventory items.", MessageType.Warning);
                        }
                    }
                    else if (assetParameters[i].parameterType == ParameterType.LocalVariable)
                    {
                        if (KickStarter.localVariables)
                        {
                            localParameters[i].intValue = ActionRunActionList.ShowVarSelectorGUI(label + ":", KickStarter.localVariables.localVars, localParameters[i].intValue);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("A GameEngine prefab is required to pass Local Variables.", MessageType.Warning);
                        }
                    }
                    else if (assetParameters[i].parameterType == ParameterType.GameObject)
                    {
                        if (isAssetFile)
                        {
                            // ID
                            localParameters[i].intValue   = EditorGUILayout.IntField(label + " (ID):", localParameters[i].intValue);
                            localParameters[i].gameObject = null;
                        }
                        else
                        {
                            // Gameobject
                            localParameters[i].gameObject = (GameObject)EditorGUILayout.ObjectField(label + ":", localParameters[i].gameObject, typeof(GameObject), true);
                            localParameters[i].intValue   = 0;
                            if (localParameters[i].gameObject != null && localParameters[i].gameObject.GetComponent <ConstantID>() == null)
                            {
                                UnityVersionHandler.AddConstantIDToGameObject <ConstantID> (localParameters[i].gameObject);
                            }
                        }
                    }
                    else if (assetParameters[i].parameterType == ParameterType.UnityObject)
                    {
                        localParameters[i].objectValue = (Object)EditorGUILayout.ObjectField(label + ":", localParameters[i].objectValue, typeof(Object), true);
                    }
                    else if (assetParameters[i].parameterType == ParameterType.ComponentVariable)
                    {
                        localParameters[i].variables = (Variables)EditorGUILayout.ObjectField("'" + label + "' component:", localParameters[i].variables, typeof(Variables), true);
                        if (localParameters[i].variables != null)
                        {
                            localParameters[i].intValue = ActionRunActionList.ShowVarSelectorGUI(label + ":", localParameters[i].variables.vars, localParameters[i].intValue);
                        }
                    }
                }

                if (i < (numParameters - 1))
                {
                    EditorGUILayout.Space();
                }
            }
        }
        private void AddCharHoles(PolygonCollider2D[] navPolys, AC.Char charToExclude, NavigationMesh navigationMesh)
        {
            if (navigationMesh.characterEvasion == CharacterEvasion.None)
            {
                return;
            }

            ResetHoles(KickStarter.sceneSettings.navMesh, false);

            for (int p = 0; p < navPolys.Length; p++)
            {
                if (p > 0)
                {
                    return;
                }

                if (navPolys[p].transform.lossyScale != Vector3.one)
                {
                    ACDebug.LogWarning("Cannot create evasion Polygons inside NavMesh '" + navPolys[p].gameObject.name + "' because it has a non-unit scale.");
                    continue;
                }

                Vector2 navPosition = navPolys[p].transform.position;

                for (int c = 0; c < KickStarter.stateHandler.Characters.Count; c++)
                {
                    AC.Char character = KickStarter.stateHandler.Characters[c];

                    CircleCollider2D circleCollider2D = character.GetComponent <CircleCollider2D>();
                    if (circleCollider2D != null &&
                        (character.charState == CharState.Idle || navigationMesh.characterEvasion == CharacterEvasion.AllCharacters) &&
                        (charToExclude == null || character != charToExclude) &&
                        UnityVersionHandler.Perform2DOverlapPoint(character.transform.position, NavigationEngine_PolygonCollider.results, 1 << KickStarter.sceneSettings.navMesh.gameObject.layer) != 0)
                    {
                        circleCollider2D.isTrigger = true;
                        List <Vector2> newPoints3D = new List <Vector2>();

                                                #if UNITY_5 || UNITY_2017_1_OR_NEWER
                        Vector2 centrePoint = character.transform.TransformPoint(circleCollider2D.offset);
                                                #else
                        Vector2 centrePoint = character.transform.TransformPoint(circleCollider2D.center);
                                                #endif

                        float radius  = circleCollider2D.radius * character.transform.localScale.x;
                        float yScaler = navigationMesh.characterEvasionYScale;

                        if (navigationMesh.characterEvasionPoints == CharacterEvasionPoints.Four)
                        {
                            newPoints3D.Add(centrePoint + new Vector2(dir_n.x * radius, dir_n.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_e.x * radius, dir_e.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_s.x * radius, dir_s.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_w.x * radius, dir_w.y * radius * yScaler));
                        }
                        else if (navigationMesh.characterEvasionPoints == CharacterEvasionPoints.Eight)
                        {
                            newPoints3D.Add(centrePoint + new Vector2(dir_n.x * radius, dir_n.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_ne.x * radius, dir_ne.y * radius * yScaler));

                            newPoints3D.Add(centrePoint + new Vector2(dir_e.x * radius, dir_e.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_se.x * radius, dir_se.y * radius * yScaler));

                            newPoints3D.Add(centrePoint + new Vector2(dir_s.x * radius, dir_s.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_sw.x * radius, dir_sw.y * radius * yScaler));

                            newPoints3D.Add(centrePoint + new Vector2(dir_w.x * radius, dir_w.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_nw.x * radius, dir_nw.y * radius * yScaler));
                        }
                        else if (navigationMesh.characterEvasionPoints == CharacterEvasionPoints.Sixteen)
                        {
                            newPoints3D.Add(centrePoint + new Vector2(dir_n.x * radius, dir_n.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_nne.x * radius, dir_nne.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_ne.x * radius, dir_ne.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_nee.x * radius, dir_nee.y * radius * yScaler));

                            newPoints3D.Add(centrePoint + new Vector2(dir_e.x * radius, dir_e.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_see.x * radius, dir_see.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_se.x * radius, dir_se.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_sse.x * radius, dir_sse.y * radius * yScaler));

                            newPoints3D.Add(centrePoint + new Vector2(dir_s.x * radius, dir_s.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_ssw.x * radius, dir_ssw.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_sw.x * radius, dir_sw.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_sww.x * radius, dir_sww.y * radius * yScaler));

                            newPoints3D.Add(centrePoint + new Vector2(dir_w.x * radius, dir_w.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_nww.x * radius, dir_nww.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_nw.x * radius, dir_nw.y * radius * yScaler));
                            newPoints3D.Add(centrePoint + new Vector2(dir_nnw.x * radius, dir_nnw.y * radius * yScaler));
                        }

                        navPolys[p].pathCount++;

                        List <Vector2> newPoints = new List <Vector2>();
                        for (int i = 0; i < newPoints3D.Count; i++)
                        {
                            // Only add a point if it is on the NavMesh
                            if (UnityVersionHandler.Perform2DOverlapPoint(newPoints3D[i], NavigationEngine_PolygonCollider.results, 1 << KickStarter.sceneSettings.navMesh.gameObject.layer) != 0)
                            {
                                newPoints.Add(newPoints3D[i] - navPosition);
                            }
                            else
                            {
                                Vector2 altPoint = GetLineIntersect(newPoints3D[i], centrePoint);
                                if (altPoint != Vector2.zero)
                                {
                                    newPoints.Add(altPoint - navPosition);
                                }
                            }
                        }

                        if (newPoints.Count > 1)
                        {
                            navPolys[p].SetPath(navPolys[p].pathCount - 1, newPoints.ToArray());
                        }
                    }
                }

                RebuildVertexArray(navPolys[p].transform, navPolys[p], p);
            }
        }
Example #22
0
        /**
         * <summary>Gets the point in world space that a point in screen space is above.</summary>
         * <param name = "screenPosition">The position in screen space</returns>
         * <param name = "onNavMesh">If True, then only objects placed on the NavMesh layer will be detected.</param>
         * <returns>The point in world space that a point in screen space is above</returns>
         */
        public Vector3 ClickPoint(Vector2 screenPosition, bool onNavMesh = false)
        {
            if (KickStarter.navigationManager.Is2D())
            {
                RaycastHit2D hit;
                if (KickStarter.mainCamera.IsOrthographic())
                {
                    if (onNavMesh)
                    {
                        hit = UnityVersionHandler.Perform2DRaycast(
                            Camera.main.ScreenToWorldPoint(new Vector2(screenPosition.x, screenPosition.y)),
                            Vector2.zero,
                            KickStarter.settingsManager.navMeshRaycastLength,
                            1 << LayerMask.NameToLayer(KickStarter.settingsManager.navMeshLayer)
                            );
                    }
                    else
                    {
                        hit = UnityVersionHandler.Perform2DRaycast(
                            Camera.main.ScreenToWorldPoint(new Vector2(screenPosition.x, screenPosition.y)),
                            Vector2.zero,
                            KickStarter.settingsManager.navMeshRaycastLength
                            );
                    }
                }
                else
                {
                    Vector3 pos = screenPosition;
                    pos.z = KickStarter.player.transform.position.z - Camera.main.transform.position.z;

                    if (onNavMesh)
                    {
                        hit = UnityVersionHandler.Perform2DRaycast(
                            Camera.main.ScreenToWorldPoint(pos),
                            Vector2.zero,
                            KickStarter.settingsManager.navMeshRaycastLength,
                            1 << LayerMask.NameToLayer(KickStarter.settingsManager.navMeshLayer)
                            );
                    }
                    else
                    {
                        hit = UnityVersionHandler.Perform2DRaycast(
                            Camera.main.ScreenToWorldPoint(pos),
                            Vector2.zero,
                            KickStarter.settingsManager.navMeshRaycastLength
                            );
                    }
                }

                if (hit.collider != null)
                {
                    return(hit.point);
                }
            }
            else
            {
                Ray        ray = Camera.main.ScreenPointToRay(screenPosition);
                RaycastHit hit = new RaycastHit();

                if (onNavMesh)
                {
                    if (KickStarter.settingsManager && KickStarter.sceneSettings && Physics.Raycast(ray, out hit, KickStarter.settingsManager.navMeshRaycastLength, 1 << LayerMask.NameToLayer(KickStarter.settingsManager.navMeshLayer)))
                    {
                        return(hit.point);
                    }
                }
                else
                {
                    if (KickStarter.settingsManager && KickStarter.sceneSettings && Physics.Raycast(ray, out hit, KickStarter.settingsManager.navMeshRaycastLength))
                    {
                        return(hit.point);
                    }
                }
            }

            return(Vector3.zero);
        }
Example #23
0
        private void UseInteractionGUI()
        {
            if (settingsManager && settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
            {
                if (_target.UpgradeSelf())
                {
                    UnityVersionHandler.CustomSetDirty(_target);
                }
            }

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Use interactions", EditorStyles.boldLabel);

            if (GUILayout.Button(addContent, EditorStyles.miniButtonRight, buttonWidth))
            {
                Undo.RecordObject(_target, "Create use interaction");
                _target.useButtons.Add(new Button());
                _target.provideUseInteraction = true;
            }
            EditorGUILayout.EndHorizontal();

            if (_target.provideUseInteraction)
            {
                if (cursorManager)
                {
                    // Create a string List of the field's names (for the PopUp box)
                    List <string> labelList = new List <string>();
                    int           iconNumber;

                    if (cursorManager.cursorIcons.Count > 0)
                    {
                        foreach (CursorIcon _icon in cursorManager.cursorIcons)
                        {
                            labelList.Add(_icon.label);
                        }

                        foreach (Button useButton in _target.useButtons)
                        {
                            iconNumber = -1;

                            int j = 0;
                            foreach (CursorIcon _icon in cursorManager.cursorIcons)
                            {
                                // If an item has been removed, make sure selected variable is still valid
                                if (_icon.id == useButton.iconID)
                                {
                                    iconNumber = j;
                                    break;
                                }
                                j++;
                            }

                            if (iconNumber == -1)
                            {
                                // Wasn't found (item was deleted?), so revert to zero
                                iconNumber       = 0;
                                useButton.iconID = 0;
                            }

                            EditorGUILayout.Space();
                            EditorGUILayout.BeginHorizontal();

                            iconNumber = CustomGUILayout.Popup("Cursor / icon:", iconNumber, labelList.ToArray(), "", "The cursor/icon associated with the interaction");

                            // Re-assign variableID based on PopUp selection
                            useButton.iconID = cursorManager.cursorIcons[iconNumber].id;
                            string iconLabel = cursorManager.cursorIcons[iconNumber].label;

                            if (GUILayout.Button("", CustomStyles.IconCog))
                            {
                                SideMenu("Use", _target.useButtons.Count, _target.useButtons.IndexOf(useButton));
                            }

                            EditorGUILayout.EndHorizontal();
                            ButtonGUI(useButton, iconLabel, _target.interactionSource);
                            GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("No cursor icons exist!");
                        iconNumber = -1;

                        for (int i = 0; i < _target.useButtons.Count; i++)
                        {
                            _target.useButtons[i].iconID = -1;
                        }
                    }
                }
                else
                {
                    ACDebug.LogWarning("A CursorManager is required to run the game properly - please open the Adventure Creator wizard and set one.");
                }
            }

            EditorGUILayout.EndVertical();
        }
Example #24
0
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            string sceneName = MultiSceneChecker.EditActiveScene();

            if (sceneName != "")
            {
                EditorGUILayout.LabelField("Editing scene: '" + sceneName + "'", CustomStyles.subHeader);
                EditorGUILayout.Space();
            }

            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();

            string label = (vars.Count > 0) ? ("Global (" + vars.Count + ")") : "Global";

            if (GUILayout.Toggle(showGlobalTab, label, "toolbarbutton"))
            {
                SetTab(0);
            }

            label = (KickStarter.localVariables != null && KickStarter.localVariables.localVars.Count > 0) ? ("Local (" + KickStarter.localVariables.localVars.Count + ")") : "Local";
            if (GUILayout.Toggle(showLocalTab, label, "toolbarbutton"))
            {
                SetTab(1);
            }

            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showSettings = CustomGUILayout.ToggleHeader(showSettings, "Editor settings");
            if (showSettings)
            {
                updateRuntime = CustomGUILayout.Toggle("Show realtime values?", updateRuntime, "AC.KickStarter.variablesManager.updateRuntime");
                filter        = EditorGUILayout.TextField("Filter by name:", filter);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            if (showGlobalTab)
            {
                varPresets = ShowPresets(varPresets, vars, VariableLocation.Global);

                if (Application.isPlaying && updateRuntime && KickStarter.runtimeVariables != null)
                {
                    ShowVarList(KickStarter.runtimeVariables.globalVars, VariableLocation.Global, false);
                }
                else
                {
                    ShowVarList(vars, VariableLocation.Global, true);

                    foreach (VarPreset varPreset in varPresets)
                    {
                        varPreset.UpdateCollection(vars);
                    }
                }
            }
            else if (showLocalTab)
            {
                if (KickStarter.localVariables != null)
                {
                    KickStarter.localVariables.varPresets = ShowPresets(KickStarter.localVariables.varPresets, KickStarter.localVariables.localVars, VariableLocation.Local);

                    if (Application.isPlaying && updateRuntime)
                    {
                        ShowVarList(KickStarter.localVariables.localVars, VariableLocation.Local, false);
                    }
                    else
                    {
                        ShowVarList(KickStarter.localVariables.localVars, VariableLocation.Local, true);
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("Local variables", CustomStyles.subHeader);
                    EditorGUILayout.HelpBox("A GameEngine prefab must be present in the scene before Local variables can be defined", MessageType.Info);
                }
            }

            EditorGUILayout.Space();
            if (selectedVar != null && (!Application.isPlaying || !updateRuntime))
            {
                int i = selectedVar.id;
                if (vars.Contains(selectedVar))
                {
                    ShowVarGUI(VariableLocation.Global, varPresets, "AC.GlobalVariables.GetVariable (" + i + ")");
                }
                else if (KickStarter.localVariables != null && KickStarter.localVariables.localVars.Contains(selectedVar))
                {
                    ShowVarGUI(VariableLocation.Local, KickStarter.localVariables.varPresets, "AC.LocalVariables.GetVariable (" + i + ")");
                }
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(this);

                if (KickStarter.localVariables != null)
                {
                    UnityVersionHandler.CustomSetDirty(KickStarter.localVariables);
                }
            }
        }
Example #25
0
        private void CheckRequiredManagerPackage()
        {
            if (requiredManagerPackage == null)
            {
                return;
            }

            if ((requiredManagerPackage.sceneManager != null && requiredManagerPackage.sceneManager != KickStarter.sceneManager) ||
                (requiredManagerPackage.settingsManager != null && requiredManagerPackage.settingsManager != KickStarter.settingsManager) ||
                (requiredManagerPackage.actionsManager != null && requiredManagerPackage.actionsManager != KickStarter.actionsManager) ||
                (requiredManagerPackage.variablesManager != null && requiredManagerPackage.variablesManager != KickStarter.variablesManager) ||
                (requiredManagerPackage.inventoryManager != null && requiredManagerPackage.inventoryManager != KickStarter.inventoryManager) ||
                (requiredManagerPackage.speechManager != null && requiredManagerPackage.speechManager != KickStarter.speechManager) ||
                (requiredManagerPackage.cursorManager != null && requiredManagerPackage.cursorManager != KickStarter.cursorManager) ||
                (requiredManagerPackage.menuManager != null && requiredManagerPackage.menuManager != KickStarter.menuManager))
            {
                if (requiredManagerPackage.settingsManager != null)
                {
                    if (requiredManagerPackage.settingsManager.name == "Demo_SettingsManager" && UnityVersionHandler.GetCurrentSceneName() == "Basement")
                    {
                        ACDebug.LogWarning("The demo scene's required Manager asset files are not all loaded - please stop the game, and choose 'Adventure Creator -> Getting started -> Load 3D Demo managers from the top toolbar, and re-load the scene.");
                        return;
                    }
                    else if (requiredManagerPackage.settingsManager.name == "Demo2D_SettingsManager" && UnityVersionHandler.GetCurrentSceneName() == "Park")
                    {
                        ACDebug.LogWarning("The 2D demo scene's required Manager asset files are not all loaded - please stop the game, and choose 'Adventure Creator -> Getting started -> Load 2D Demo managers from the top toolbar, and re-load the scene.");
                        return;
                    }
                }

                ACDebug.LogWarning("This scene's required Manager asset files are not all loaded - please find the asset file '" + requiredManagerPackage.name + "' and click 'Assign managers' in its Inspector.");
            }
        }
Example #26
0
        public override void OnInspectorGUI()
        {
            GameCamera _target = (GameCamera)target;

            _target.ShowCursorInfluenceGUI();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("X-axis movement", EditorStyles.boldLabel);

            _target.lockXLocAxis = CustomGUILayout.Toggle("Lock?", _target.lockXLocAxis, "", "If True, movement in the X-axis is prevented");

            if (!_target.lockXLocAxis)
            {
                _target.xLocConstrainType = (CameraLocConstrainType)CustomGUILayout.EnumPopup("Affected by:", _target.xLocConstrainType, "", "The constrain type on X-axis movement");

                EditorGUILayout.BeginVertical("Button");
                if (_target.xLocConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    _target.xFreedom = CustomGUILayout.FloatField("Track freedom:", _target.xFreedom, "", "The track freedom along the X-axis");
                }
                else
                {
                    _target.xGradient = CustomGUILayout.FloatField("Influence:", _target.xGradient, "", "The influence of the target's position on X-axis movement");
                }
                _target.xOffset = CustomGUILayout.FloatField("Offset:", _target.xOffset, "", "The X-axis position offset");
                EditorGUILayout.EndVertical();

                _target.limitX = CustomGUILayout.Toggle("Constrain?", _target.limitX, "", "If True, then X-axis movement will be limited to minimum and maximum values");
                if (_target.limitX)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.constrainX[0] = CustomGUILayout.FloatField("Minimum constraint:", _target.constrainX[0], "", "The lower X-axis movement limit");
                    _target.constrainX[1] = CustomGUILayout.FloatField("Maximum constraint:", _target.constrainX[1], "", "The upper X-axis movement limit");
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Y-axis movement", EditorStyles.boldLabel);

            _target.lockYLocAxis = CustomGUILayout.Toggle("Lock?", _target.lockYLocAxis, "", "If True, movement in the Y-axis is prevented");

            if (!_target.lockYLocAxis)
            {
                _target.yLocConstrainType = (CameraLocConstrainType)CustomGUILayout.EnumPopup("Affected by:", _target.yLocConstrainType, "", "The constrain type on Y-axis movement");

                EditorGUILayout.BeginVertical("Button");
                if (_target.yLocConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    _target.yFreedom = CustomGUILayout.FloatField("Track freedom:", _target.yFreedom, "", "The track freedom along the Y-axis");
                }
                else
                {
                    _target.yGradientLoc = CustomGUILayout.FloatField("Influence:", _target.yGradientLoc, "", "The influence of the target's position on Y-axis movement");
                }
                _target.yOffsetLoc = CustomGUILayout.FloatField("Offset:", _target.yOffsetLoc, "", "The Y-axis position offset");
                EditorGUILayout.EndVertical();

                _target.limitYLoc = CustomGUILayout.Toggle("Constrain?", _target.limitYLoc, "", "If True, then Y-axis movement will be limited to minimum and maximum values");
                if (_target.limitYLoc)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.constrainYLoc[0] = CustomGUILayout.FloatField("Minimum constraint:", _target.constrainYLoc[0], "", "The lower Y-axis movement limit");
                    _target.constrainYLoc[1] = CustomGUILayout.FloatField("Maximum constraint:", _target.constrainYLoc[1], "", "The upper Y-axis movement limit");
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Z-axis movement", EditorStyles.boldLabel);

            _target.lockZLocAxis = CustomGUILayout.Toggle("Lock?", _target.lockZLocAxis, "", "If True, movement in the Z-axis is prevented");

            if (!_target.lockZLocAxis)
            {
                _target.zLocConstrainType = (CameraLocConstrainType)CustomGUILayout.EnumPopup("Affected by:", _target.zLocConstrainType, "", "The constrain type on Z-axis movement");

                EditorGUILayout.BeginVertical("Button");
                if (_target.zLocConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    _target.zFreedom = CustomGUILayout.FloatField("Track freedom:", _target.zFreedom, "", "The track freedom along the Z-axis");
                }
                else
                {
                    _target.zGradient = CustomGUILayout.FloatField("Influence:", _target.zGradient, "", "The influence of the target's position on Z-axis movement");
                }
                _target.zOffset = CustomGUILayout.FloatField("Offset:", _target.zOffset, "", "The Z-axis position offset");
                EditorGUILayout.EndVertical();

                _target.limitZ = CustomGUILayout.Toggle("Constrain?", _target.limitZ, "", "If True, then Z-axis movement will be limited to minimum and maximum values");
                if (_target.limitZ)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.constrainZ[0] = CustomGUILayout.FloatField("Minimum constraint:", _target.constrainZ[0], "", "The lower Z-axis movement limit");
                    _target.constrainZ[1] = CustomGUILayout.FloatField("Maximum constraint:", _target.constrainZ[1], "", "The upper Z-axis movement limit");
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Spin rotation", EditorStyles.boldLabel);

            _target.lockYRotAxis = CustomGUILayout.Toggle("Lock?", _target.lockYRotAxis, "", "If True, spin rotation is prevented");

            if (!_target.lockYRotAxis)
            {
                _target.yRotConstrainType = (CameraRotConstrainType)CustomGUILayout.EnumPopup("Affected by:", _target.yRotConstrainType, "", "The constrain type on spin rotation");

                if (_target.yRotConstrainType != CameraRotConstrainType.LookAtTarget)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.directionInfluence = CustomGUILayout.FloatField("Target direction fac.:", _target.directionInfluence, "", "The influence that the target's facing direction has on the tracking position");
                    _target.yGradient          = CustomGUILayout.FloatField("Influence:", _target.yGradient, "", "The influence of the target's position on spin rotation");
                    _target.yOffset            = CustomGUILayout.FloatField("Offset:", _target.yOffset, "", "The spin rotation offset");
                    EditorGUILayout.EndVertical();
                }
                else
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.directionInfluence = CustomGUILayout.FloatField("Target direction fac.:", _target.directionInfluence, "", "The influence that the target's facing direction has on the tracking position");
                    _target.targetHeight       = CustomGUILayout.FloatField("Target height offset:", _target.targetHeight, "", "The target positional offset in the Y-axis");
                    _target.targetXOffset      = CustomGUILayout.FloatField("Target X offset:", _target.targetXOffset, "", "The target positional offset in the X-axis");
                    _target.targetZOffset      = CustomGUILayout.FloatField("Target Z offset:", _target.targetZOffset, "", "The target positional offset in the Z-axis");
                    EditorGUILayout.EndVertical();
                }

                _target.limitY = CustomGUILayout.Toggle("Constrain?", _target.limitY, "", "If True, then spin rotation will be limited to minimum and maximum values");
                if (_target.limitY)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.constrainY[0] = CustomGUILayout.FloatField("Minimum constraint:", _target.constrainY[0], "", "The lower spin rotation limit");
                    _target.constrainY[1] = CustomGUILayout.FloatField("Maximum constraint:", _target.constrainY[1], "", "The upper spin rotation limit");
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Pitch rotation", EditorStyles.boldLabel);

            if (!_target.lockYRotAxis && _target.yRotConstrainType == CameraRotConstrainType.LookAtTarget)
            {
                EditorGUILayout.HelpBox("Pitch rotation is overriden by 'Look At Target' spin rotation.", MessageType.Info);

                _target.limitXRot = CustomGUILayout.Toggle("Constrain?", _target.limitXRot, "", "If True, then pitch rotation will be limited to minimum and maximum values");
            }
            else
            {
                _target.lockXRotAxis = CustomGUILayout.Toggle("Lock?", _target.lockXRotAxis, "", "If True, pitch rotation is prevented");

                if (!_target.lockXRotAxis)
                {
                    _target.xRotConstrainType = (CameraLocConstrainType)CustomGUILayout.EnumPopup("Affected by:", _target.xRotConstrainType, "", "The constrain type on pitch rotation");

                    if (_target.xRotConstrainType == CameraLocConstrainType.SideScrolling)
                    {
                        EditorGUILayout.HelpBox("This option is not available for Pitch rotation", MessageType.Warning);
                    }
                    else
                    {
                        EditorGUILayout.BeginVertical("Button");
                        _target.xGradientRot = CustomGUILayout.FloatField("Influence:", _target.xGradientRot, "", "The influence of the target's position on pitch rotation");
                        _target.xOffsetRot   = CustomGUILayout.FloatField("Offset:", _target.xOffsetRot, "", "The pitch rotation offset");
                        EditorGUILayout.EndVertical();
                    }

                    _target.limitXRot = CustomGUILayout.Toggle("Constrain?", _target.limitXRot, "", "If True, then pitch rotation will be limited to minimum and maximum values");
                    if (_target.limitXRot)
                    {
                        EditorGUILayout.BeginVertical("Button");
                        _target.constrainXRot[0] = CustomGUILayout.FloatField("Minimum constraint:", _target.constrainXRot[0], "", "The lower pitch rotation limit");
                        _target.constrainXRot[1] = CustomGUILayout.FloatField("Maximum constraint:", _target.constrainXRot[1], "", "The upper pitch rotation limit");
                        EditorGUILayout.EndVertical();
                    }
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            if (_target.GetComponent <Camera>() && _target.GetComponent <Camera>().orthographic)
            {
                EditorGUILayout.LabelField("Orthographic size", EditorStyles.boldLabel);
            }
            else if (_target.GetComponentInChildren <Camera>() && _target.GetComponentInChildren <Camera>().orthographic)
            {
                EditorGUILayout.LabelField("Orthographic size", EditorStyles.boldLabel);
            }
            else
            {
                EditorGUILayout.LabelField("Field of view", EditorStyles.boldLabel);
            }

            _target.lockFOV = CustomGUILayout.Toggle("Lock?", _target.lockFOV, "", "If True, changing of the FOV is prevented");

            if (!_target.lockFOV)
            {
                EditorGUILayout.HelpBox("This value will vary with the target's distance from the camera.", MessageType.Info);

                EditorGUILayout.BeginVertical("Button");
                _target.FOVGradient = CustomGUILayout.FloatField("Influence:", _target.FOVGradient, "", "The influence of the target's position on FOV");
                _target.FOVOffset   = CustomGUILayout.FloatField("Offset:", _target.FOVOffset, "", "The FOV offset");
                EditorGUILayout.EndVertical();

                _target.limitFOV = CustomGUILayout.Toggle("Constrain?", _target.limitFOV, "", "If True, then FOV will be limited to minimum and maximum value");
                if (_target.limitFOV)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.constrainFOV[0] = CustomGUILayout.FloatField("Minimum constraint:", _target.constrainFOV[0], "", "The lower FOV limit");
                    _target.constrainFOV[1] = CustomGUILayout.FloatField("Maximum constraint:", _target.constrainFOV[1], "", "The upper FOV limit");
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Depth of field", EditorStyles.boldLabel);
            _target.focalPointIsTarget = CustomGUILayout.Toggle("Focal point is target object?", _target.focalPointIsTarget, "", "If True, then the focal distance will match the distance to the target");
            if (!_target.focalPointIsTarget)
            {
                _target.focalDistance = CustomGUILayout.FloatField("Focal distance:", _target.focalDistance, "", "The camera's focal distance.  When the MainCamera is attached to this camera, it can be read through script with 'AC.KickStarter.mainCamera.GetFocalDistance()' and used to update your post-processing method.");
            }
            else if (Application.isPlaying)
            {
                EditorGUILayout.LabelField("Focal distance: " + _target.focalDistance.ToString(), EditorStyles.miniLabel);
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            if (!_target.lockXLocAxis || !_target.lockYRotAxis || !_target.lockFOV || !_target.lockYLocAxis || !_target.lockZLocAxis || _target.focalPointIsTarget)
            {
                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.LabelField("Target object to control camera movement", EditorStyles.boldLabel);

                _target.targetIsPlayer = CustomGUILayout.Toggle("Target is Player?", _target.targetIsPlayer, "", "If True, the camera will follow the active Player");

                if (!_target.targetIsPlayer)
                {
                    _target.target = (Transform)CustomGUILayout.ObjectField <Transform> ("Target:", _target.target, true, "", "The object for the camera to follow");
                }

                _target.dampSpeed = CustomGUILayout.FloatField("Follow speed:", _target.dampSpeed, "", "The follow speed when tracking a target");
                _target.actFromDefaultPlayerStart = CustomGUILayout.Toggle("Use default PlayerStart?", _target.actFromDefaultPlayerStart, "", "If True, then the camera's position will be relative to the scene's default PlayerStart, rather then the Player's initial position. This ensures that camera movement is the same regardless of where the Player begins in the scene");
                EditorGUILayout.EndVertical();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
Example #27
0
        public override void OnInspectorGUI()
        {
            GameCameraThirdPerson _target = (GameCameraThirdPerson)target;

            // Target
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Target", EditorStyles.boldLabel);
            _target.targetIsPlayer = EditorGUILayout.Toggle("Is player?", _target.targetIsPlayer);
            if (!_target.targetIsPlayer)
            {
                _target.target = (Transform)EditorGUILayout.ObjectField("Target transform:", _target.target, typeof(Transform), true);
            }
            _target.horizontalOffset = EditorGUILayout.FloatField("Horizontal offset:", _target.horizontalOffset);
            _target.verticalOffset   = EditorGUILayout.FloatField("Vertical offset:", _target.verticalOffset);
            EditorGUILayout.EndVertical();

            // Distance
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Distance", EditorStyles.boldLabel);
            _target.distance = EditorGUILayout.FloatField("Distance from target:", _target.distance);
            _target.allowMouseWheelZooming = EditorGUILayout.Toggle("Mousewheel zooming?", _target.allowMouseWheelZooming);
            _target.detectCollisions       = EditorGUILayout.Toggle("Detect wall collisions?", _target.detectCollisions);

            if (_target.detectCollisions)
            {
                _target.collisionOffset = EditorGUILayout.FloatField("Collision offset:", _target.collisionOffset);
                if (_target.collisionOffset < 0f)
                {
                    _target.collisionOffset = 0f;
                }
                _target.collisionLayerMask = AdvGame.LayerMaskField("Collision layer(s):", _target.collisionLayerMask);
            }
            if (_target.allowMouseWheelZooming || _target.detectCollisions)
            {
                _target.minDistance = EditorGUILayout.FloatField("Mininum distance:", _target.minDistance);
            }
            if (_target.allowMouseWheelZooming)
            {
                _target.maxDistance = EditorGUILayout.FloatField("Maximum distance:", _target.maxDistance);
            }
            EditorGUILayout.EndVertical();

            // Spin
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Spin rotation", EditorStyles.boldLabel, GUILayout.Width(130f));
            _target.spinLock = (RotationLock)EditorGUILayout.EnumPopup(_target.spinLock);
            EditorGUILayout.EndHorizontal();
            if (_target.spinLock != RotationLock.Locked)
            {
                _target.spinSpeed                    = EditorGUILayout.FloatField("Speed:", _target.spinSpeed);
                _target.spinAccleration              = EditorGUILayout.FloatField("Acceleration:", _target.spinAccleration);
                _target.spinDeceleration             = EditorGUILayout.FloatField("Deceleration:", _target.spinDeceleration);
                _target.isDragControlled             = EditorGUILayout.Toggle("Drag-controlled?", _target.isDragControlled);
                _target.canRotateDuringConversations = EditorGUILayout.ToggleLeft("Can rotate during Conversations?", _target.canRotateDuringConversations);
                if (!_target.isDragControlled)
                {
                    _target.spinAxis = EditorGUILayout.TextField("Input axis:", _target.spinAxis);
                }
                _target.inputAffectsSpeed   = EditorGUILayout.ToggleLeft("Scale speed with input magnitude?", _target.inputAffectsSpeed);
                _target.invertSpin          = EditorGUILayout.Toggle("Invert?", _target.invertSpin);
                _target.toggleCursor        = EditorGUILayout.Toggle("Cursor must be locked?", _target.toggleCursor);
                _target.resetSpinWhenSwitch = EditorGUILayout.Toggle("Reset angle on switch?", _target.resetSpinWhenSwitch);

                if (_target.spinLock == RotationLock.Limited)
                {
                    _target.maxSpin = EditorGUILayout.FloatField("Maximum angle:", _target.maxSpin);
                }
            }

            if (_target.spinLock != RotationLock.Free)
            {
                _target.alwaysBehind = EditorGUILayout.Toggle("Always behind target?", _target.alwaysBehind);
                if (_target.alwaysBehind)
                {
                    _target.spinAccleration = EditorGUILayout.FloatField("Acceleration:", _target.spinAccleration);
                    _target.spinOffset      = EditorGUILayout.FloatField("Offset angle:", _target.spinOffset);
                }
            }
            EditorGUILayout.EndVertical();

            // Pitch
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Pitch rotation", EditorStyles.boldLabel, GUILayout.Width(130f));
            _target.pitchLock = (RotationLock)EditorGUILayout.EnumPopup(_target.pitchLock);
            EditorGUILayout.EndHorizontal();
            if (_target.pitchLock != RotationLock.Locked)
            {
                _target.pitchSpeed                   = EditorGUILayout.FloatField("Speed:", _target.pitchSpeed);
                _target.pitchAccleration             = EditorGUILayout.FloatField("Acceleration:", _target.pitchAccleration);
                _target.pitchDeceleration            = EditorGUILayout.FloatField("Deceleration:", _target.pitchDeceleration);
                _target.isDragControlled             = EditorGUILayout.Toggle("Drag-controlled?", _target.isDragControlled);
                _target.canRotateDuringConversations = EditorGUILayout.ToggleLeft("Can rotate during Conversations?", _target.canRotateDuringConversations);
                if (!_target.isDragControlled)
                {
                    _target.pitchAxis = EditorGUILayout.TextField("Input axis:", _target.pitchAxis);
                }
                _target.inputAffectsSpeed    = EditorGUILayout.ToggleLeft("Scale speed with input magnitude?", _target.inputAffectsSpeed);
                _target.invertPitch          = EditorGUILayout.Toggle("Invert?", _target.invertPitch);
                _target.resetPitchWhenSwitch = EditorGUILayout.Toggle("Reset angle on switch?", _target.resetPitchWhenSwitch);

                if (_target.pitchLock == RotationLock.Limited)
                {
                    _target.maxPitch = EditorGUILayout.FloatField("Maximum angle:", _target.maxPitch);
                    _target.minPitch = EditorGUILayout.FloatField("Minimum angle:", _target.minPitch);
                }
            }
            else
            {
                _target.maxPitch = EditorGUILayout.FloatField("Fixed angle:", _target.maxPitch);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Depth of field", EditorStyles.boldLabel);
            _target.focalPointIsTarget = EditorGUILayout.Toggle("Focal point is target object?", _target.focalPointIsTarget);
            if (!_target.focalPointIsTarget)
            {
                _target.focalDistance = EditorGUILayout.FloatField("Focal distance:", _target.focalDistance);
            }
            else if (Application.isPlaying)
            {
                EditorGUILayout.LabelField("Focal distance: " + _target.focalDistance.ToString(), EditorStyles.miniLabel);
            }
            EditorGUILayout.EndVertical();

            DisplayInputList(_target);

            UnityVersionHandler.CustomSetDirty(_target);
        }
Example #28
0
        private void Export()
        {
                        #if UNITY_WEBPLAYER
            ACDebug.LogWarning("Game text cannot be exported in WebPlayer mode - please switch platform and try again.");
                        #else
            if (variablesManager == null || exportColumns == null || exportColumns.Count == 0)
            {
                return;
            }

            bool canProceed = EditorUtility.DisplayDialog("Export variables", "AC will now go through your game, and collect all variables to be exported.\n\nIt is recommended to back up your project beforehand.", "OK", "Cancel");
            if (!canProceed)
            {
                return;
            }

            if (!UnityVersionHandler.SaveSceneIfUserWants())
            {
                return;
            }

            string suggestedFilename = "";
            if (AdvGame.GetReferences().settingsManager)
            {
                suggestedFilename = AdvGame.GetReferences().settingsManager.saveFileName + " - ";
            }
            suggestedFilename += "Variables.csv";

            string fileName = EditorUtility.SaveFilePanel("Export variables", "Assets", suggestedFilename, "csv");
            if (fileName.Length == 0)
            {
                return;
            }

            List <GVar> exportVars = new List <GVar>();
            foreach (GVar globalVariable in variablesManager.vars)
            {
                exportVars.Add(new GVar(globalVariable));
            }

            bool            fail   = false;
            List <string[]> output = new List <string[]>();

            List <string> headerList = new List <string>();
            headerList.Add("ID");
            foreach (ExportColumn exportColumn in exportColumns)
            {
                headerList.Add(exportColumn.GetHeader());
            }
            output.Add(headerList.ToArray());

            foreach (GVar exportVar in exportVars)
            {
                List <string> rowList = new List <string>();
                rowList.Add(exportVar.id.ToString());
                foreach (ExportColumn exportColumn in exportColumns)
                {
                    string cellText = exportColumn.GetCellText(exportVar, VariableLocation.Global);
                    rowList.Add(cellText);

                    if (cellText.Contains(CSVReader.csvDelimiter))
                    {
                        fail = true;
                        ACDebug.LogError("Cannot export variables since global variable " + exportVar.id.ToString() + " (" + exportVar.label + ") contains the character '" + CSVReader.csvDelimiter + "'.");
                    }
                }
                output.Add(rowList.ToArray());
            }

            // Local
            int      numLocalVars  = 0;
            string   originalScene = UnityVersionHandler.GetCurrentSceneFilepath();
            string[] sceneFiles    = AdvGame.GetSceneFiles();
            foreach (string sceneFile in sceneFiles)
            {
                UnityVersionHandler.OpenScene(sceneFile);

                List <GVar> localExportVars = new List <GVar>();
                if (FindObjectOfType <LocalVariables>())
                {
                    LocalVariables localVariables = FindObjectOfType <LocalVariables>();
                    string         sceneName      = UnityVersionHandler.GetCurrentSceneName();

                    foreach (GVar localVariable in localVariables.localVars)
                    {
                        localExportVars.Add(new GVar(localVariable));
                    }

                    foreach (GVar localExportVar in localExportVars)
                    {
                        numLocalVars++;

                        List <string> rowList = new List <string>();
                        rowList.Add(localExportVar.id.ToString());
                        foreach (ExportColumn exportColumn in exportColumns)
                        {
                            string cellText = exportColumn.GetCellText(localExportVar, VariableLocation.Local, sceneName);
                            rowList.Add(cellText);

                            if (cellText.Contains(CSVReader.csvDelimiter))
                            {
                                fail = true;
                                ACDebug.LogError("Cannot export variables since local variable " + localExportVar.id.ToString() + " (" + localExportVar.label + ") contains the character '" + CSVReader.csvDelimiter + "'.");
                            }
                        }
                        output.Add(rowList.ToArray());
                    }
                }
            }

            if (originalScene == "")
            {
                UnityVersionHandler.NewScene();
            }
            else
            {
                UnityVersionHandler.OpenScene(originalScene);
            }

            if (!fail)
            {
                int length = output.Count;

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                for (int j = 0; j < length; j++)
                {
                    sb.AppendLine(string.Join(CSVReader.csvDelimiter, output[j]));
                }

                if (Serializer.SaveFile(fileName, sb.ToString()))
                {
                    ACDebug.Log((exportVars.Count - 1).ToString() + " global variables, " + numLocalVars.ToString() + " local variables exported.");
                }
            }

            //this.Close ();
                        #endif
        }
        public override void OnInspectorGUI()
        {
            ActionListAsset _target = (ActionListAsset)target;

            ShowPropertiesGUI(_target);
            EditorGUILayout.Space();

            if (actionsManager == null)
            {
                EditorGUILayout.HelpBox("An Actions Manager asset file must be assigned in the Game Editor Window", MessageType.Warning);
                OnEnable();
                UnityVersionHandler.CustomSetDirty(_target);
                return;
            }

            if (actionsManager.displayActionsInInspector)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Expand all", EditorStyles.miniButtonLeft))
                {
                    Undo.RecordObject(_target, "Expand actions");
                    foreach (AC.Action action in _target.actions)
                    {
                        action.isDisplayed = true;
                    }
                }
                if (GUILayout.Button("Collapse all", EditorStyles.miniButtonMid))
                {
                    Undo.RecordObject(_target, "Collapse actions");
                    foreach (AC.Action action in _target.actions)
                    {
                        action.isDisplayed = false;
                    }
                }
                if (GUILayout.Button("Action List Editor", EditorStyles.miniButtonMid))
                {
                    ActionListEditorWindow.Init(_target);
                }
                GUI.enabled = Application.isPlaying;
                if (GUILayout.Button("Run now", EditorStyles.miniButtonRight))
                {
                    if (KickStarter.actionListAssetManager != null)
                    {
                        if (!_target.canRunMultipleInstances)
                        {
                            int numRemoved = KickStarter.actionListAssetManager.EndAssetList(_target);
                            if (numRemoved > 0)
                            {
                                ACDebug.Log("Removed 1 instance of ActionList asset '" + _target.name + "' because it is set to only run one at a time.", _target);
                            }
                        }

                        AdvGame.RunActionListAsset(_target);
                    }
                    else
                    {
                        ACDebug.LogWarning("An AC PersistentEngine object must be present in the scene for ActionList assets to run.", _target);
                    }
                }
                GUI.enabled = true;
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                if (Application.isPlaying)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Edit Actions", GUILayout.Height(40f)))
                    {
                        ActionListEditorWindow.Init(_target);
                    }
                    if (GUILayout.Button("Run now", GUILayout.Height(40f)))
                    {
                        AdvGame.RunActionListAsset(_target);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    if (GUILayout.Button("Edit Actions", GUILayout.Height(40f)))
                    {
                        ActionListEditorWindow.Init(_target);
                    }
                }
                UnityVersionHandler.CustomSetDirty(_target);
                return;
            }

            EditorGUILayout.Space();

            for (int i = 0; i < _target.actions.Count; i++)
            {
                int typeIndex = actionsManager.GetActionTypeIndex(_target.actions[i]);

                if (_target.actions[i] == null)
                {
                    RebuildAction(_target.actions[i], typeIndex, _target, i);
                }

                _target.actions[i].isAssetFile = true;

                EditorGUILayout.BeginVertical("Button");

                string actionLabel = " (" + i + ") " + actionsManager.GetActionTypeLabel(_target.actions[i], true);
                actionLabel = actionLabel.Replace("\r\n", "");
                actionLabel = actionLabel.Replace("\n", "");
                actionLabel = actionLabel.Replace("\r", "");
                if (actionLabel.Length > 40)
                {
                    actionLabel = actionLabel.Substring(0, 40) + "..)";
                }

                EditorGUILayout.BeginHorizontal();
                _target.actions[i].isDisplayed = EditorGUILayout.Foldout(_target.actions[i].isDisplayed, actionLabel);
                if (!_target.actions[i].isEnabled)
                {
                    EditorGUILayout.LabelField("DISABLED", EditorStyles.boldLabel, GUILayout.Width(100f));
                }

                if (GUILayout.Button("", CustomStyles.IconCog))
                {
                    ActionSideMenu(_target.actions[i]);
                }
                EditorGUILayout.EndHorizontal();

                if (_target.actions[i].isDisplayed)
                {
                    if (!actionsManager.DoesActionExist(_target.actions[i].GetType().ToString()))
                    {
                        EditorGUILayout.HelpBox("This Action type is not listed in the Actions Manager", MessageType.Warning);
                    }
                    else
                    {
                        int newTypeIndex = ActionListEditor.ShowTypePopup(_target.actions[i], typeIndex);
                        if (newTypeIndex >= 0)
                        {
                            // Rebuild constructor if Subclass and type string do not match
                            ActionEnd _end = new ActionEnd();
                            _end.resultAction   = _target.actions[i].endAction;
                            _end.skipAction     = _target.actions[i].skipAction;
                            _end.linkedAsset    = _target.actions[i].linkedAsset;
                            _end.linkedCutscene = _target.actions[i].linkedCutscene;

                            Undo.RecordObject(_target, "Change Action type");

                            RebuildAction(_target.actions[i], newTypeIndex, _target, i, _end);
                        }

                        EditorGUILayout.Space();
                        GUI.enabled = _target.actions[i].isEnabled;

                        if (Application.isPlaying)
                        {
                            _target.actions[i].AssignValues(_target.GetParameters());
                        }

                        _target.actions[i].ShowGUI(_target.GetParameters());
                    }
                    GUI.enabled = true;
                }

                if (_target.actions[i].endAction == AC.ResultAction.Skip || _target.actions[i] is ActionCheck || _target.actions[i] is ActionCheckMultiple || _target.actions[i] is ActionParallel)
                {
                    _target.actions[i].SkipActionGUI(_target.actions, _target.actions[i].isDisplayed);
                }

                EditorGUILayout.EndVertical();
                EditorGUILayout.Space();
            }

            if (GUILayout.Button("Add new Action"))
            {
                Undo.RecordObject(_target, "Create action");
                AddAction(ActionsManager.GetDefaultAction(), _target.actions.Count, _target);
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
Example #30
0
        public override void OnInspectorGUI()
        {
            GameCamera2D _target = (GameCamera2D)target;

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Horizontal movement", EditorStyles.boldLabel);

            _target.lockHorizontal = EditorGUILayout.Toggle("Lock?", _target.lockHorizontal);
            if (!_target.GetComponent <Camera>().orthographic || !_target.lockHorizontal)
            {
                _target.afterOffset.x = EditorGUILayout.FloatField("Offset:", _target.afterOffset.x);
            }

            if (!_target.lockHorizontal)
            {
                _target.freedom.x            = EditorGUILayout.FloatField("Track freedom:", _target.freedom.x);
                _target.directionInfluence.x = EditorGUILayout.FloatField("Target direction fac.:", _target.directionInfluence.x);
                _target.limitHorizontal      = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitHorizontal);

                EditorGUILayout.BeginVertical("Button");
                _target.constrainHorizontal[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainHorizontal[0]);
                _target.constrainHorizontal[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainHorizontal[1]);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndToggleGroup();
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Vertical movement", EditorStyles.boldLabel);

            _target.lockVertical = EditorGUILayout.Toggle("Lock?", _target.lockVertical);
            if (!_target.GetComponent <Camera>().orthographic || !_target.lockVertical)
            {
                _target.afterOffset.y = EditorGUILayout.FloatField("Offset:", _target.afterOffset.y);
            }

            if (!_target.lockVertical)
            {
                _target.freedom.y            = EditorGUILayout.FloatField("Track freedom:", _target.freedom.y);
                _target.directionInfluence.y = EditorGUILayout.FloatField("Target direction fac.:", _target.directionInfluence.y);
                _target.limitVertical        = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitVertical);

                EditorGUILayout.BeginVertical("Button");
                _target.constrainVertical[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainVertical[0]);
                _target.constrainVertical[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainVertical[1]);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndToggleGroup();
            }
            EditorGUILayout.EndVertical();

            if (!_target.lockHorizontal || !_target.lockVertical)
            {
                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.LabelField("Target object to control camera movement", EditorStyles.boldLabel);

                _target.targetIsPlayer = EditorGUILayout.Toggle("Target is player?", _target.targetIsPlayer);

                if (!_target.targetIsPlayer)
                {
                    _target.target = (Transform)EditorGUILayout.ObjectField("Target:", _target.target, typeof(Transform), true);
                }

                _target.dampSpeed = EditorGUILayout.FloatField("Follow speed", _target.dampSpeed);
                EditorGUILayout.EndVertical();
            }

            if (!_target.IsCorrectRotation())
            {
                if (GUILayout.Button("Set correct rotation"))
                {
                    Undo.RecordObject(_target, "Clear " + _target.name + " rotation");
                    _target.SetCorrectRotation();
                }
            }

            if (!Application.isPlaying)
            {
                _target.GetComponent <Camera>().ResetProjectionMatrix();
                if (!_target.GetComponent <Camera>().orthographic)
                {
                    _target.SetCameraComponent();
                    _target.SnapToOffset();
                }
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }