Пример #1
0
        public override void OnInspectorGUI()
        {
            SortingMap _target = (SortingMap)target;

            EditorGUILayout.BeginVertical("Button");
            _target.mapType     = (SortingMapType)EditorGUILayout.EnumPopup("Affect sprite's:", _target.mapType);
            _target.affectScale = EditorGUILayout.Toggle("Affect Character scale?", _target.affectScale);
            if (_target.affectScale)
            {
                _target.affectSpeed = EditorGUILayout.Toggle("Affect Character speed?", _target.affectSpeed);
                _target.originScale = EditorGUILayout.IntField("Start scale (%):", _target.originScale);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            foreach (SortingArea area in _target.sortingAreas)
            {
                int i = _target.sortingAreas.IndexOf(area);

                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.BeginHorizontal();

                area.color = EditorGUILayout.ColorField(area.color);

                EditorGUILayout.LabelField("Position:", GUILayout.Width(50f));
                area.z = EditorGUILayout.FloatField(area.z, GUILayout.Width(80f));

                if (_target.mapType == SortingMapType.OrderInLayer)
                {
                    EditorGUILayout.LabelField("Order:", labelWidth);
                    area.order = EditorGUILayout.IntField(area.order);
                }
                else if (_target.mapType == SortingMapType.SortingLayer)
                {
                    EditorGUILayout.LabelField("Layer:", labelWidth);
                    area.layer = EditorGUILayout.TextField(area.layer);
                }

                if (GUILayout.Button(insertContent, EditorStyles.miniButtonLeft, buttonWidth))
                {
                    Undo.RecordObject(_target, "Add area");
                    if (i < _target.sortingAreas.Count - 1)
                    {
                        _target.sortingAreas.Insert(i + 1, new SortingArea(area, _target.sortingAreas[i + 1]));
                    }
                    else
                    {
                        _target.sortingAreas.Insert(i + 1, new SortingArea(area));
                    }
                    break;
                }
                if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                {
                    Undo.RecordObject(_target, "Delete area");
                    _target.sortingAreas.Remove(area);
                    break;
                }

                EditorGUILayout.EndHorizontal();

                if (_target.affectScale)
                {
                    area.scale = EditorGUILayout.IntField("End scale (%):", area.scale);
                }

                EditorGUILayout.EndVertical();
            }

            if (GUILayout.Button("Add area"))
            {
                Undo.RecordObject(_target, "Add area");

                if (_target.sortingAreas.Count > 0)
                {
                    SortingArea lastArea = _target.sortingAreas [_target.sortingAreas.Count - 1];
                    _target.sortingAreas.Add(new SortingArea(lastArea));
                }
                else
                {
                    _target.sortingAreas.Add(new SortingArea(_target.transform.position.z + 1f, 1));
                }
            }

            EditorGUILayout.Space();

            if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.IsTopDown())
            {
            }
            else if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.IsUnity2D())
            {
            }
            else
            {
                if (GUILayout.Button("Face active camera"))
                {
                    Undo.RecordObject(_target, "Face active camera");
                    Vector3 forwardVector = Camera.main.transform.forward;
                    _target.transform.forward = -forwardVector;
                    EditorUtility.SetDirty(_target);
                }
            }

            if (_target.affectScale && _target.sortingAreas.Count > 1)
            {
                if (GUILayout.Button("Interpolate in-between scales"))
                {
                    Undo.RecordObject(_target, "Interpolate scales");
                    _target.SetInBetweenScales();
                    EditorUtility.SetDirty(_target);
                }
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(_target);
            }
        }
Пример #2
0
        public void InitialiseObjects()
        {
            CreateFolder("_Cameras");
            CreateFolder("_Cutscenes");
            CreateFolder("_DialogueOptions");
            CreateFolder("_Interactions");
            CreateFolder("_Lights");
            CreateFolder("_Logic");
            CreateFolder("_Moveables");
            CreateFolder("_Navigation");
            CreateFolder("_NPCs");
            CreateFolder("_Sounds");
            CreateFolder("_SetGeometry");
            CreateFolder("_UI");

            // Create subfolders
            CreateSubFolder("_Cameras", "_GameCameras");

            CreateSubFolder("_Logic", "_ArrowPrompts");
            CreateSubFolder("_Logic", "_Conversations");
            CreateSubFolder("_Logic", "_Containers");
            CreateSubFolder("_Logic", "_Hotspots");
            CreateSubFolder("_Logic", "_Triggers");

            CreateSubFolder("_Moveables", "_Tracks");

            CreateSubFolder("_Navigation", "_CollisionCubes");
            CreateSubFolder("_Navigation", "_CollisionCylinders");
            CreateSubFolder("_Navigation", "_Markers");
            CreateSubFolder("_Navigation", "_NavMeshSegments");
            CreateSubFolder("_Navigation", "_NavMesh");
            CreateSubFolder("_Navigation", "_Paths");
            CreateSubFolder("_Navigation", "_PlayerStarts");
            CreateSubFolder("_Navigation", "_SortingMaps");

            // Delete default main camera
            if (GameObject.FindWithTag(Tags.mainCamera))
            {
                GameObject mainCam = GameObject.FindWithTag(Tags.mainCamera);
                if (mainCam.GetComponent <MainCamera>() == null)
                {
                    DestroyImmediate(mainCam);
                }
            }

            // Create main camera
            SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;
            GameObject      mainCamOb       = AddPrefab("Automatic", "MainCamera", false, false, false);

            PrefabUtility.DisconnectPrefabInstance(mainCamOb);
            PutInFolder(GameObject.FindWithTag(Tags.mainCamera), "_Cameras");
            if (settingsManager && settingsManager.IsUnity2D())
            {
                Camera.main.orthographic = true;
            }

            // Create Background Camera (if 2.5D)
            if (settingsManager && settingsManager.cameraPerspective == CameraPerspective.TwoPointFiveD)
            {
                CreateSubFolder("_SetGeometry", "_BackgroundImages");
                GameObject newOb = AddPrefab("Automatic", "BackgroundCamera", false, false, false);
                PutInFolder(newOb, "_Cameras");
            }

            // Create Game engine
            AddPrefab("Automatic", "GameEngine", false, false, false);

            // Assign Player Start
            if (KickStarter.sceneSettings && KickStarter.sceneSettings.defaultPlayerStart == null)
            {
                string playerStartPrefab = "PlayerStart";
                if (settingsManager != null && settingsManager.IsUnity2D())
                {
                    playerStartPrefab += "2D";
                }

                PlayerStart playerStart = AddPrefab("Navigation", playerStartPrefab, true, false, true).GetComponent <PlayerStart>();
                KickStarter.sceneSettings.defaultPlayerStart = playerStart;
            }

            // Pathfinding method
            if (settingsManager != null && settingsManager.IsUnity2D())
            {
                KickStarter.sceneSettings.navigationMethod = AC_NavigationMethod.PolygonCollider;
                KickStarter.navigationManager.ResetEngine();
            }
        }
Пример #3
0
        private void DeclareScenePrefabs()
        {
            scenePrefabs = new List <ScenePrefab>();
            SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;

            if (settingsManager == null || settingsManager.cameraPerspective == CameraPerspective.ThreeD)
            {
                scenePrefabs.Add(new ScenePrefab("Camera", "GameCamera", "Camera/GameCamera", "_GameCameras", "The standard camera type for 3D games.", "GameCamera"));
                scenePrefabs.Add(new ScenePrefab("Camera", "GameCamera Animated", "Camera/GameCameraAnimated", "_GameCameras", "Plays an Animation Clip when active, or syncs it with its target's position.", "GameCameraAnimated"));
                scenePrefabs.Add(new ScenePrefab("Camera", "GameCamera Third-person", "Camera/GameCameraThirdPerson", "_GameCameras", "Rigidly follows its target, but can still be rotated.", "GameCameraThirdPerson"));
                scenePrefabs.Add(new ScenePrefab("Camera", "SimpleCamera", "Camera/SimpleCamera", "_GameCameras", "A stationary but lightweight 3D camera.", "GameCamera"));
            }
            else
            {
                if (settingsManager.cameraPerspective == CameraPerspective.TwoD)
                {
                    scenePrefabs.Add(new ScenePrefab("Camera", "GameCamera 2D", "Camera/GameCamera2D", "_GameCameras", "The standard camera type for 2D games.", "GameCamera2D"));
                }
                else
                {
                    scenePrefabs.Add(new ScenePrefab("Camera", "GameCamera 2.5D", "Camera/GameCamera2.5D", "_GameCameras", "A stationary camera that can display images in the background.", "GameCamera25D"));
                    scenePrefabs.Add(new ScenePrefab("Camera", "Background Image", "SetGeometry/BackgroundImage", "_BackgroundImages", "A container for a 2.5D camera's background image.", "BackgroundImage"));
                    scenePrefabs.Add(new ScenePrefab("Camera", "Scene sprite", "SetGeometry/SceneSprite", "_SetGeometry", "An in-scene sprite for 2.5D games.", "", "SceneSprite"));
                }
            }

            scenePrefabs.Add(new ScenePrefab("Logic", "Arrow prompt", "Logic/ArrowPrompt", "_ArrowPrompts", "An on-screen directional prompt for the player.", "ArrowPrompt"));
            scenePrefabs.Add(new ScenePrefab("Logic", "Conversation", "Logic/Conversation", "_Conversations", "Stores a list of Dialogue Options, from which the player can choose.", "Conversation"));
            scenePrefabs.Add(new ScenePrefab("Logic", "Container", "Logic/Container", "_Containers", "Can store a list of Inventory Items, for the player to retrieve and add to.", "Container"));
            scenePrefabs.Add(new ScenePrefab("Logic", "Cutscene", "Logic/Cutscene", "_Cutscenes", "A sequence of Actions that can form a cinematic.", "Cutscene"));
            scenePrefabs.Add(new ScenePrefab("Logic", "Dialogue Option", "Logic/DialogueOption", "_DialogueOptions", "An option available to the player when a Conversation is active.", "DialogueOption"));

            if (settingsManager != null && settingsManager.IsUnity2D())
            {
                scenePrefabs.Add(new ScenePrefab("Logic", "Hotspot 2D", "Logic/Hotspot2D", "_Hotspots", "A portion of the scene that can be interacted with.", "Hotspot"));
            }
            else
            {
                scenePrefabs.Add(new ScenePrefab("Logic", "Hotspot", "Logic/Hotspot", "_Hotspots", "A portion of the scene that can be interacted with.", "Hotspot"));
            }

            scenePrefabs.Add(new ScenePrefab("Logic", "Interaction", "Logic/Interaction", "_Interactions", "A sequence of Actions that run when a Hotspot is activated.", "Interaction"));
            scenePrefabs.Add(new ScenePrefab("Logic", "Sound", "Logic/Sound", "_Sounds", "An audio source that syncs with AC's sound levels.", "Sound"));

            if (settingsManager != null && settingsManager.IsUnity2D())
            {
                scenePrefabs.Add(new ScenePrefab("Logic", "Trigger 2D", "Logic/Trigger2D", "_Triggers", "A portion of the scene that responds to objects entering it.", "AC_Trigger"));
            }
            else
            {
                scenePrefabs.Add(new ScenePrefab("Logic", "Trigger", "Logic/Trigger", "_Triggers", "A portion of the scene that responds to objects entering it.", "AC_Trigger"));
            }

            scenePrefabs.Add(new ScenePrefab("Moveable", "Draggable", "Moveable/Draggable", "_Moveables", "Can move along pre-defined Tracks, along planes, or be rotated about its centre.", "Moveable_Drag"));
            scenePrefabs.Add(new ScenePrefab("Moveable", "PickUp", "Moveable/PickUp", "_Moveables", "Can be grabbed, rotated and thrown freely in 3D space.", "Moveable_PickUp"));
            scenePrefabs.Add(new ScenePrefab("Moveable", "Straight Track", "Moveable/StraightTrack", "_Tracks", "Constrains a Drag object along a straight line, optionally adding rolling or screw effects.", "DragTrack_Straight"));
            scenePrefabs.Add(new ScenePrefab("Moveable", "Curved Track", "Moveable/CurvedTrack", "_Tracks", "Constrains a Drag object along a circular line.", "DragTrack_Curved"));
            scenePrefabs.Add(new ScenePrefab("Moveable", "Hinge Track", "Moveable/HingeTrack", "_Tracks", "Constrains a Drag object's position, only allowing it to rotate in a circular motion.", "DragTrack_Hinge"));

            scenePrefabs.Add(new ScenePrefab("Navigation", "SortingMap", "Navigation/SortingMap", "_SortingMaps", "Defines how sprites are scaled and sorted relative to one another.", "SortingMap"));

            if (settingsManager != null && settingsManager.IsUnity2D())
            {
                scenePrefabs.Add(new ScenePrefab("Navigation", "Collision Cube 2D", "Navigation/CollisionCube2D", "_CollisionCubes", "Blocks Character movement, as well as cursor clicks if placed on the Default layer.", "_Collision"));
                scenePrefabs.Add(new ScenePrefab("Navigation", "Marker 2D", "Navigation/Marker2D", "_Markers", "A point in the scene used by Characters and objects.", "Marker"));
            }
            else
            {
                scenePrefabs.Add(new ScenePrefab("Navigation", "Collision Cube", "Navigation/CollisionCube", "_CollisionCubes", "Blocks Character movement, as well as cursor clicks if placed on the Default layer.", "_Collision"));
                scenePrefabs.Add(new ScenePrefab("Navigation", "Collision Cylinder", "Navigation/CollisionCylinder", "_CollisionCylinders", "Blocks Character movement, as well as cursor clicks if placed on the Default layer.", "_Collision"));
                scenePrefabs.Add(new ScenePrefab("Navigation", "Marker", "Navigation/Marker", "_Markers", "A point in the scene used by Characters and objects.", "Marker"));
            }

            if (KickStarter.sceneSettings)
            {
                AC_NavigationMethod engine = KickStarter.sceneSettings.navigationMethod;
                if (engine == AC_NavigationMethod.meshCollider)
                {
                    scenePrefabs.Add(new ScenePrefab("Navigation", "NavMesh", "Navigation/NavMesh", "_NavMesh", "A mesh that defines the area that Characters can move in.", "NavigationMesh"));
                }
                else if (engine == AC_NavigationMethod.PolygonCollider)
                {
                    scenePrefabs.Add(new ScenePrefab("Navigation", "NavMesh 2D", "Navigation/NavMesh2D", "_NavMesh", "A polygon that defines the area that Characters can move in.", "NavigationMesh"));
                }
                else if (engine == AC_NavigationMethod.UnityNavigation)
                {
                    scenePrefabs.Add(new ScenePrefab("Navigation", "NavMesh segment", "Navigation/NavMeshSegment", "_NavMeshSegments", "A plane that defines a portion of the area that Characters can move in.", "NavMeshSegment"));
                    scenePrefabs.Add(new ScenePrefab("Navigation", "Static obstacle", "Navigation/StaticObstacle", "_NavMeshSegments", "A cube that defines a portion of the area that Characters cannot move in.", "", "StaticObstacle"));
                }
            }

            scenePrefabs.Add(new ScenePrefab("Navigation", "Path", "Navigation/Path", "_Paths", "A sequence of points that describe a Character's movement.", "Paths"));

            if (settingsManager != null && settingsManager.IsUnity2D())
            {
                scenePrefabs.Add(new ScenePrefab("Navigation", "PlayerStart 2D", "Navigation/PlayerStart2D", "_PlayerStarts", "A point in the scene from which the Player begins.", "PlayerStart"));
            }
            else
            {
                scenePrefabs.Add(new ScenePrefab("Navigation", "PlayerStart", "Navigation/PlayerStart", "_PlayerStarts", "A point in the scene from which the Player begins.", "PlayerStart"));
            }
        }
Пример #4
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;
                        go.transform.parent   = _target.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();

                if (KickStarter.cursorManager != null && KickStarter.cursorManager.AllowUnhandledIcons())
                {
                    EditorGUILayout.Space();
                    UnhandledUseInteractionGUI();
                }

                EditorGUILayout.Space();
                UnhandledInvInteractionGUI();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
Пример #5
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            location = (VariableLocation)EditorGUILayout.EnumPopup("Source:", location);

            if (isAssetFile && getVarMethod == GetVarMethod.LocalVariable)
            {
                EditorGUILayout.HelpBox("Local Variables cannot be referenced by Asset-based Actions.", MessageType.Warning);
                return;
            }

            switch (location)
            {
            case VariableLocation.Global:
                if (AdvGame.GetReferences().variablesManager)
                {
                    VariablesManager variablesManager = AdvGame.GetReferences().variablesManager;

                    parameterID = Action.ChooseParameterGUI("Variable:", parameters, parameterID, ParameterType.GlobalVariable);
                    if (parameterID >= 0)
                    {
                        SetPlaceholderVar(variablesManager.vars, variableID);
                        ShowPlaceholderVar();
                        variableID = ShowVarGUI(parameters, variablesManager.vars, variableID, false);
                    }
                    else
                    {
                        setPlaceholder = false;
                        variableID     = ShowVarGUI(parameters, variablesManager.vars, variableID, true);
                    }
                }
                break;

            case VariableLocation.Local:
                if (localVariables != null)
                {
                    parameterID = Action.ChooseParameterGUI("Variable:", parameters, parameterID, ParameterType.LocalVariable);
                    if (parameterID >= 0)
                    {
                        SetPlaceholderVar(localVariables.localVars, variableID);
                        ShowPlaceholderVar();
                        variableID = ShowVarGUI(parameters, localVariables.localVars, variableID, false);
                    }
                    else
                    {
                        setPlaceholder = false;
                        variableID     = ShowVarGUI(parameters, localVariables.localVars, variableID, true);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("No 'Local Variables' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info);
                }
                break;

            case VariableLocation.Component:
                parameterID = Action.ChooseParameterGUI("Variable:", parameters, parameterID, ParameterType.ComponentVariable);
                if (parameterID >= 0)
                {
                    ShowPlaceholderVar();
                    variableID = ShowVarGUI(parameters, (variables != null) ? variables.vars : null, variableID, false);
                }
                else
                {
                    variables           = (Variables)EditorGUILayout.ObjectField("Component:", variables, typeof(Variables), true);
                    variablesConstantID = FieldToID <Variables> (variables, variablesConstantID);
                    variables           = IDToField <Variables> (variables, variablesConstantID, false);

                    if (variables != null)
                    {
                        variableID     = ShowVarGUI(parameters, variables.vars, variableID, true);
                        setPlaceholder = false;
                        SetPlaceholderVar(variables.vars, variableID);
                    }
                }
                break;
            }
        }
Пример #6
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            numSockets = EditorGUILayout.DelayedIntField("# of possible values:", numSockets);
            numSockets = Mathf.Clamp(numSockets, 1, 100);

            disallowSuccessive = EditorGUILayout.Toggle("Prevent same value twice?", disallowSuccessive);

            if (disallowSuccessive)
            {
                saveToVariable = EditorGUILayout.Toggle("Save last value?", saveToVariable);
                if (saveToVariable)
                {
                    location = (VariableLocation)EditorGUILayout.EnumPopup("Variable source:", location);

                    if (location == VariableLocation.Local && KickStarter.localVariables == null)
                    {
                        EditorGUILayout.HelpBox("No 'Local Variables' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info);
                    }
                    else if (location == VariableLocation.Local && isAssetFile)
                    {
                        EditorGUILayout.HelpBox("Local variables cannot be accessed in ActionList assets.", MessageType.Info);
                    }

                    if ((location == VariableLocation.Global && AdvGame.GetReferences().variablesManager != null) ||
                        (location == VariableLocation.Local && KickStarter.localVariables != null && !isAssetFile) ||
                        (location == VariableLocation.Component))
                    {
                        ParameterType _parameterType = ParameterType.GlobalVariable;
                        if (location == VariableLocation.Local)
                        {
                            _parameterType = ParameterType.LocalVariable;
                        }
                        else if (location == VariableLocation.Component)
                        {
                            _parameterType = ParameterType.ComponentVariable;
                        }

                        parameterID = Action.ChooseParameterGUI("Integer variable:", parameters, parameterID, _parameterType);
                        if (parameterID >= 0)
                        {
                            if (location == VariableLocation.Component)
                            {
                                variablesConstantID = 0;
                                variables           = null;
                            }

                            variableID = ShowVarGUI(variableID, false);
                        }
                        else
                        {
                            if (location == VariableLocation.Component)
                            {
                                variables           = (Variables)EditorGUILayout.ObjectField("Component:", variables, typeof(Variables), true);
                                variablesConstantID = FieldToID <Variables> (variables, variablesConstantID);
                                variables           = IDToField <Variables> (variables, variablesConstantID, false);

                                if (variables != null)
                                {
                                    variableID = ShowVarGUI(variableID, true);
                                }
                            }
                            else
                            {
                                EditorGUILayout.BeginHorizontal();
                                variableID = ShowVarGUI(variableID, true);

                                if (GUILayout.Button(string.Empty, CustomStyles.IconCog))
                                {
                                    SideMenu();
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                    }
                }
            }
        }
Пример #7
0
        protected void DrawSharedElements(ActionList _target)
        {
            if (IsActionListPrefab(_target))
            {
                EditorGUILayout.HelpBox("Scene-based Actions can not live in prefabs - use ActionList assets instead.", MessageType.Info);
                return;
            }

            int numActions = 0;

            if (_target.source != ActionListSource.AssetFile)
            {
                numActions = _target.actions.Count;
                if (numActions < 1)
                {
                    numActions = 1;
                    AddAction(ActionsManager.GetDefaultAction(), -1, _target);
                }
            }

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

            if (_target.source == ActionListSource.AssetFile)
            {
                GUI.enabled = false;
            }

            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;
                }
            }

            GUI.enabled = true;

            if (GUILayout.Button("Action List Editor", EditorStyles.miniButtonMid))
            {
                if (_target.source == ActionListSource.AssetFile)
                {
                    if (_target.assetFile != null)
                    {
                        ActionListEditorWindow.Init(_target.assetFile);
                    }
                }
                else
                {
                    ActionListEditorWindow.Init(_target);
                }
            }
            if (!Application.isPlaying)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("Run now", EditorStyles.miniButtonRight))
            {
                _target.Interact();
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            if (_target.source == ActionListSource.AssetFile)
            {
                return;
            }

            ActionListEditor.ResetList(_target);

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

            if (!actionsManager.displayActionsInInspector)
            {
                EditorGUILayout.HelpBox("As set by the Actions Manager, Actions are only displayed in the ActionList Editor window.", MessageType.Info);
                return;
            }

            for (int i = 0; i < _target.actions.Count; i++)
            {
                if (_target.actions[i] == null)
                {
                    ACDebug.LogWarning("An empty Action was found, and was deleted", _target);
                    _target.actions.RemoveAt(i);
                    numActions--;
                    continue;
                }

                _target.actions[i].AssignParentList(_target);

                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.BeginHorizontal();
                int typeIndex = actionsManager.GetActionTypeIndex(_target.actions[i]);

                string actionLabel = " (" + i.ToString() + ") " + 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) + "..)";
                }

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

                if (GUILayout.Button("", CustomStyles.IconCog))
                {
                    ActionSideMenu(i);
                }

                _target.actions[i].isAssetFile = false;

                EditorGUILayout.EndHorizontal();

                if (_target.actions[i].isBreakPoint)
                {
                    EditorGUILayout.HelpBox("Break point", MessageType.None);
                }

                if (_target.actions[i].isDisplayed)
                {
                    GUI.enabled = _target.actions[i].isEnabled;

                    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");
                            _target.actions[i] = RebuildAction(_target.actions[i], newTypeIndex, _target, -1, _end);
                        }

                        if (_target.useParameters && _target.parameters != null && _target.parameters.Count > 0)
                        {
                            _target.actions[i].ShowGUI(_target.parameters);
                        }
                        else
                        {
                            _target.actions[i].ShowGUI(null);
                        }
                    }
                }

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

                GUI.enabled = true;

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

            if (GUILayout.Button("Add new action"))
            {
                Undo.RecordObject(_target, "Create action");
                numActions += 1;
            }

            _target = ActionListEditor.ResizeList(_target, numActions);
        }
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            onlyPreload = EditorGUILayout.ToggleLeft("Don't change scene, just preload data?", onlyPreload);

            if (!onlyPreload)
            {
                relativePosition = EditorGUILayout.ToggleLeft("Position Player relative to Marker?", relativePosition);
                if (relativePosition)
                {
                    relativeMarkerParameterID = Action.ChooseParameterGUI("Relative Marker:", parameters, relativeMarkerParameterID, ParameterType.GameObject);
                    if (relativeMarkerParameterID >= 0)
                    {
                        relativeMarkerID = 0;
                        relativeMarker   = null;
                    }
                    else
                    {
                        relativeMarker = (Marker)EditorGUILayout.ObjectField("Relative Marker:", relativeMarker, typeof(Marker), true);

                        relativeMarkerID = FieldToID(relativeMarker, relativeMarkerID);
                        relativeMarker   = IDToField(relativeMarker, relativeMarkerID, false);
                    }
                }
            }

            if (onlyPreload && !relativePosition)
            {
                if (AdvGame.GetReferences() != null && AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.useAsyncLoading)
                {
                }
                else
                {
                    EditorGUILayout.HelpBox("To pre-load scenes, 'Load scenes asynchronously?' must be enabled in the Settings Manager.", MessageType.Warning);
                }

                numSockets = 1;
                AfterRunningOption();
            }
            else
            {
                numSockets          = 0;
                assignScreenOverlay = EditorGUILayout.ToggleLeft("Overlay current screen during switch?", assignScreenOverlay);
            }
        }
Пример #9
0
        private void CreateScript()
        {
                        #if UNITY_WEBPLAYER
            ACDebug.LogWarning("Game text cannot be exported in WebPlayer mode - please switch platform and try again.");
                        #else
            if (AdvGame.GetReferences() == null || AdvGame.GetReferences().speechManager == null)
            {
                ACDebug.LogError("Cannot create script sheet - no Speech Manager is assigned!");
                return;
            }

            SpeechManager speechManager = AdvGame.GetReferences().speechManager;
            languageIndex = Mathf.Max(languageIndex, 0);

            string suggestedFilename = "Adventure Creator";
            if (AdvGame.GetReferences().settingsManager)
            {
                suggestedFilename = AdvGame.GetReferences().settingsManager.saveFileName;
            }
            if (limitToCharacter && characterName != "")
            {
                suggestedFilename += " (" + characterName + ")";
            }
            if (limitToTag && tagID >= 0)
            {
                SpeechTag speechTag = speechManager.GetSpeechTag(tagID);
                if (speechTag != null && speechTag.label.Length > 0)
                {
                    suggestedFilename += " (" + speechTag.label + ")";
                }
            }
            suggestedFilename += " - ";
            if (languageIndex > 0)
            {
                suggestedFilename += speechManager.languages[languageIndex] + " ";
            }
            suggestedFilename += "script.html";

            string fileName = EditorUtility.SaveFilePanel("Save script file", "Assets", suggestedFilename, "html");
            if (fileName.Length == 0)
            {
                return;
            }

            string gameName = "Adventure Creator";
            if (AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.saveFileName.Length > 0)
            {
                gameName = AdvGame.GetReferences().settingsManager.saveFileName;
                if (languageIndex > 0)
                {
                    gameName += " (" + speechManager.languages[languageIndex] + ")";
                }
            }

            System.Text.StringBuilder script = new System.Text.StringBuilder();
            script.Append("<html>\n<head>\n");
            script.Append("<meta http-equiv='Content-Type' content='text/html;charset=ISO-8859-1' charset='UTF-8'>\n");
            script.Append("<title>" + gameName + "</title>\n");
            script.Append("<style> body, table, div, p, dl { font: 400 14px/22px Roboto,sans-serif; } footer { text-align: center; padding-top: 20px; font-size: 12px;} footer a { color: blue; text-decoration: none} </style>\n</head>\n");
            script.Append("<body>\n");

            script.Append("<h1>" + gameName + " - script sheet");
            if (limitToCharacter && characterName != "")
            {
                script.Append(" (" + characterName + ")");
            }
            script.Append("</h1>\n");
            script.Append("<h2>Created: " + DateTime.UtcNow.ToString("HH:mm dd MMMM, yyyy") + "</h2>\n");

            // By scene
            foreach (string sceneFile in speechManager.sceneFiles)
            {
                List <SpeechLine> sceneSpeechLines = new List <SpeechLine>();

                int    slashPoint = sceneFile.LastIndexOf("/") + 1;
                string sceneName  = sceneFile.Substring(slashPoint);

                foreach (SpeechLine line in speechManager.lines)
                {
                    if (line.textType == AC_TextType.Speech &&
                        (line.scene == sceneFile || sceneName == (line.scene + ".unity")) &&
                        (!limitToCharacter || characterName == "" || line.owner == characterName || (line.isPlayer && characterName == "Player")) &&
                        (!limitToTag || line.tagID == tagID))
                    {
                        if (limitToMissingAudio && line.HasAudio(languageIndex))
                        {
                            continue;
                        }

                        sceneSpeechLines.Add(line);
                    }
                }

                if (sceneSpeechLines != null && sceneSpeechLines.Count > 0)
                {
                    sceneSpeechLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.OrderIdentifier.CompareTo(b.OrderIdentifier)); });

                    script.Append("<hr/>\n<h3><b>Scene:</b> " + sceneName + "</h3>\n");
                    foreach (SpeechLine sceneSpeechLine in sceneSpeechLines)
                    {
                        script.Append(sceneSpeechLine.Print(languageIndex, includeDescriptions, removeTokens));
                    }
                }
            }

            // No scene
            List <SpeechLine> assetSpeechLines = new List <SpeechLine>();

            foreach (SpeechLine line in speechManager.lines)
            {
                if (line.scene == "" &&
                    line.textType == AC_TextType.Speech &&
                    (!limitToCharacter || characterName == "" || line.owner == characterName || (line.isPlayer && characterName == "Player")) &&
                    (!limitToTag || line.tagID == tagID))
                {
                    if (limitToMissingAudio && line.HasAudio(languageIndex))
                    {
                        continue;
                    }

                    assetSpeechLines.Add(line);
                }
            }

            if (assetSpeechLines != null && assetSpeechLines.Count > 0)
            {
                assetSpeechLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.OrderIdentifier.CompareTo(b.OrderIdentifier)); });

                script.Append("<hr/>\n<h3>Scene-independent lines:</h3>\n");
                foreach (SpeechLine assetSpeechLine in assetSpeechLines)
                {
                    script.Append(assetSpeechLine.Print(languageIndex, includeDescriptions, removeTokens));
                }
            }

            script.Append("<footer>Generated by <a href='http://adventurecreator.org' target=blank>Adventure Creator</a>, by Chris Burton</footer>\n");
            script.Append("</body>\n</html>");

            Serializer.SaveFile(fileName, script.ToString());
                        #endif

            this.Close();
        }
Пример #10
0
        public override void ShowGUI(MenuSource source)
        {
            EditorGUILayout.BeginVertical("Button");
            if (source == MenuSource.AdventureCreator)
            {
                textEffects = (TextEffects)EditorGUILayout.EnumPopup("Text effect:", textEffects);
                if (textEffects != TextEffects.None)
                {
                    outlineSize = EditorGUILayout.Slider("Effect size:", outlineSize, 1f, 5f);
                }
            }
            displayType      = (ConversationDisplayType)EditorGUILayout.EnumPopup("Display:", displayType);
            inventoryBoxType = (AC_InventoryBoxType)EditorGUILayout.EnumPopup("Inventory box type:", inventoryBoxType);
            if (inventoryBoxType == AC_InventoryBoxType.Default || inventoryBoxType == AC_InventoryBoxType.CustomScript)
            {
                limitToCategory = EditorGUILayout.Toggle("Limit to category?", limitToCategory);
                if (limitToCategory)
                {
                    if (AdvGame.GetReferences().inventoryManager)
                    {
                        List <string> binList = new List <string>();
                        List <InvBin> bins    = AdvGame.GetReferences().inventoryManager.bins;
                        foreach (InvBin bin in bins)
                        {
                            binList.Add(bin.label);
                        }

                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("Category:", GUILayout.Width(146f));
                        if (binList.Count > 0)
                        {
                            int binNumber = GetBinSlot(categoryID, bins);
                            binNumber  = EditorGUILayout.Popup(binNumber, binList.ToArray());
                            categoryID = bins[binNumber].id;
                        }
                        else
                        {
                            categoryID = -1;
                            EditorGUILayout.LabelField("No categories defined!", EditorStyles.miniLabel, GUILayout.Width(146f));
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No Inventory Manager defined!", MessageType.Warning);
                        categoryID = -1;
                    }
                }
                else
                {
                    categoryID = -1;
                }

                maxSlots = EditorGUILayout.IntSlider("Max number of slots:", maxSlots, 1, 30);

                isClickable = true;
            }
            else if (inventoryBoxType == AC_InventoryBoxType.DisplaySelected)
            {
                isClickable = false;
                maxSlots    = 1;
            }
            else if (inventoryBoxType == AC_InventoryBoxType.DisplayLastSelected)
            {
                isClickable = true;
                maxSlots    = 1;
            }
            else if (inventoryBoxType == AC_InventoryBoxType.Container)
            {
                isClickable            = true;
                maxSlots               = EditorGUILayout.IntSlider("Max number of slots:", maxSlots, 1, 30);
                selectItemsAfterTaking = EditorGUILayout.Toggle("Select item after taking?", selectItemsAfterTaking);
            }
            else
            {
                isClickable = true;
                if (source == MenuSource.AdventureCreator)
                {
                    numSlots = EditorGUILayout.IntField("Test slots:", numSlots);
                }
                maxSlots = EditorGUILayout.IntSlider("Max number of slots:", maxSlots, 1, 30);
            }

            if (inventoryBoxType == AC_InventoryBoxType.HotspotBased)
            {
                limitToDefinedInteractions = EditorGUILayout.ToggleLeft("Only show items referenced in Interactions?", limitToDefinedInteractions);
            }

            if (inventoryBoxType != AC_InventoryBoxType.DisplaySelected && inventoryBoxType != AC_InventoryBoxType.DisplayLastSelected && source == MenuSource.AdventureCreator)
            {
                slotSpacing = EditorGUILayout.Slider("Slot spacing:", slotSpacing, 0f, 20f);
                orientation = (ElementOrientation)EditorGUILayout.EnumPopup("Slot orientation:", orientation);
                if (orientation == ElementOrientation.Grid)
                {
                    gridWidth = EditorGUILayout.IntSlider("Grid size:", gridWidth, 1, 10);
                }
            }

            if (inventoryBoxType == AC_InventoryBoxType.CustomScript)
            {
                ShowClipHelp();
            }

            if (source != MenuSource.AdventureCreator)
            {
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical("Button");
                uiHideStyle = (UIHideStyle)EditorGUILayout.EnumPopup("When invisible:", uiHideStyle);
                EditorGUILayout.LabelField("Linked button objects", EditorStyles.boldLabel);

                uiSlots = ResizeUISlots(uiSlots, maxSlots);

                for (int i = 0; i < uiSlots.Length; i++)
                {
                    uiSlots[i].LinkedUiGUI(i, source);
                }
            }
            EditorGUILayout.EndVertical();


            base.ShowGUI(source);
        }
Пример #11
0
        private void PopulateList()
        {
            if (Application.isPlaying)
            {
                if (inventoryBoxType == AC_InventoryBoxType.HotspotBased)
                {
                    if (limitToDefinedInteractions)
                    {
                        items = KickStarter.runtimeInventory.MatchInteractions();
                    }
                    else
                    {
                        items = KickStarter.runtimeInventory.localItems;
                    }
                }
                else if (inventoryBoxType == AC_InventoryBoxType.DisplaySelected)
                {
                    items = KickStarter.runtimeInventory.GetSelected();
                }
                else if (inventoryBoxType == AC_InventoryBoxType.DisplayLastSelected)
                {
                    if (KickStarter.runtimeInventory.selectedItem != null)
                    {
                        items = new List <InvItem>();
                        items = KickStarter.runtimeInventory.GetSelected();
                    }
                    else if (items.Count == 1 && !KickStarter.runtimeInventory.IsItemCarried(items[0]))
                    {
                        items.Clear();
                    }
                }
                else if (inventoryBoxType == AC_InventoryBoxType.Container)
                {
                    if (KickStarter.playerInput.activeContainer)
                    {
                        items.Clear();
                        foreach (ContainerItem containerItem in KickStarter.playerInput.activeContainer.items)
                        {
                            InvItem referencedItem = new InvItem(KickStarter.inventoryManager.GetItem(containerItem.linkedID));
                            referencedItem.count = containerItem.count;
                            items.Add(referencedItem);
                        }
                    }
                }
                else
                {
                    items = new List <InvItem>();
                    foreach (InvItem _item in KickStarter.runtimeInventory.localItems)
                    {
                        items.Add(_item);
                    }
                }
            }
            else
            {
                items = new List <InvItem>();
                if (AdvGame.GetReferences().inventoryManager)
                {
                    foreach (InvItem _item in AdvGame.GetReferences().inventoryManager.items)
                    {
                        items.Add(_item);
                        if (_item != null)
                        {
                            _item.recipeSlot = -1;
                        }
                    }
                }
            }

            if (inventoryBoxType == AC_InventoryBoxType.Default || inventoryBoxType == AC_InventoryBoxType.CustomScript)
            {
                if (limitToCategory && categoryID > -1)
                {
                    while (AreAnyItemsInWrongCategory())
                    {
                        foreach (InvItem _item in items)
                        {
                            if (_item != null && _item.binID != categoryID)
                            {
                                items.Remove(_item);
                                break;
                            }
                        }
                    }
                }

                while (AreAnyItemsInRecipe())
                {
                    foreach (InvItem _item in items)
                    {
                        if (_item != null && _item.recipeSlot > -1)
                        {
                            if (AdvGame.GetReferences().settingsManager.canReorderItems)
                            {
                                items [items.IndexOf(_item)] = null;
                            }
                            else
                            {
                                items.Remove(_item);
                            }
                            break;
                        }
                    }
                }
            }
        }
Пример #12
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            // OLD

            if (isAssetFile)
            {
                oldLocation = VariableLocation.Global;
            }
            else
            {
                oldLocation = (VariableLocation)EditorGUILayout.EnumPopup("'From' source:", oldLocation);
            }

            if (oldLocation == VariableLocation.Global)
            {
                if (AdvGame.GetReferences().variablesManager)
                {
                    oldVariableID = ShowVarGUI(AdvGame.GetReferences().variablesManager.vars, parameters, ParameterType.GlobalVariable, oldVariableID, oldParameterID, false);
                }
            }
            else if (oldLocation == VariableLocation.Local)
            {
                if (localVariables)
                {
                    oldVariableID = ShowVarGUI(localVariables.localVars, parameters, ParameterType.LocalVariable, oldVariableID, oldParameterID, false);
                }
            }

            EditorGUILayout.Space();

            // NEW

            if (isAssetFile)
            {
                newLocation = VariableLocation.Global;
            }
            else
            {
                newLocation = (VariableLocation)EditorGUILayout.EnumPopup("'To' source:", newLocation);
            }

            if (newLocation == VariableLocation.Global)
            {
                if (AdvGame.GetReferences().variablesManager)
                {
                    newVariableID = ShowVarGUI(AdvGame.GetReferences().variablesManager.vars, parameters, ParameterType.GlobalVariable, newVariableID, newParameterID, true);
                }
            }
            else if (newLocation == VariableLocation.Local)
            {
                if (localVariables)
                {
                    newVariableID = ShowVarGUI(localVariables.localVars, parameters, ParameterType.LocalVariable, newVariableID, newParameterID, true);
                }
                else
                {
                    EditorGUILayout.HelpBox("No 'Local Variables' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info);
                }
            }

            // Types match?
            if (oldParameterID == -1 && newParameterID == -1 && newVarType != oldVarType)
            {
                EditorGUILayout.HelpBox("The chosen Variables do not share the same Type - a conversion will be attemped", MessageType.Info);
            }

            AfterRunningOption();
        }
Пример #13
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is player?", isPlayer);
            if (!isPlayer)
            {
                parameterID = ChooseParameterGUI("Object:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID  = 0;
                    shapeObject = null;
                }
                else
                {
                    shapeObject = (Shapeable)EditorGUILayout.ObjectField("Object:", shapeObject, typeof(Shapeable), true);

                    constantID  = FieldToID <Shapeable> (shapeObject, constantID);
                    shapeObject = IDToField <Shapeable> (shapeObject, constantID, false);
                }
            }
            else
            {
                Player _player = null;

                if (Application.isPlaying)
                {
                    _player = KickStarter.player;
                }
                else
                {
                    _player = AdvGame.GetReferences().settingsManager.GetDefaultPlayer();
                }

                if (_player != null && _player.GetShapeable())
                {
                    shapeObject = _player.GetShapeable();
                }
                else
                {
                    shapeObject = null;
                    EditorGUILayout.HelpBox("Cannot find player with Shapeable script attached", MessageType.Warning);
                }
            }

            if (shapeObject != null && shapeObject.shapeGroups != null)
            {
                shapeGroupID   = ActionBlendShape.ShapeableGroupGUI("Shape group:", shapeObject.shapeGroups, shapeGroupID);
                disableAllKeys = EditorGUILayout.Toggle("Disable all keys?", disableAllKeys);
                if (!disableAllKeys)
                {
                    ShapeGroup _shapeGroup = shapeObject.GetGroup(shapeGroupID);
                    if (_shapeGroup != null)
                    {
                        if (_shapeGroup.shapeKeys != null && _shapeGroup.shapeKeys.Count > 0)
                        {
                            shapeKeyID = ShapeableKeyGUI(_shapeGroup.shapeKeys, shapeKeyID);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("No shape keys found.", MessageType.Info);
                        }
                    }
                    shapeValue = EditorGUILayout.Slider("New value:", shapeValue, 0f, 100f);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("An object must be assigned before more options can show.", MessageType.Info);
            }

            fadeTime = EditorGUILayout.FloatField("Transition time:", fadeTime);
            if (fadeTime > 0f)
            {
                moveMethod = (MoveMethod)EditorGUILayout.EnumPopup("Move method:", moveMethod);
                if (moveMethod == MoveMethod.CustomCurve)
                {
                    timeCurve = EditorGUILayout.CurveField("Time curve:", timeCurve);
                }
                willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
            }

            AfterRunningOption();
        }
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            numSockets = EditorGUILayout.IntSlider("# of possible values:", numSockets, 1, 20);
            doLoop     = EditorGUILayout.Toggle("Run on a loop?", doLoop);

            saveToVariable = EditorGUILayout.Toggle("Save sequence value?", saveToVariable);
            if (saveToVariable)
            {
                if (isAssetFile)
                {
                    location = VariableLocation.Global;
                }
                else
                {
                    location = (VariableLocation)EditorGUILayout.EnumPopup("Source:", location);
                }

                if (location == VariableLocation.Global)
                {
                    if (AdvGame.GetReferences().variablesManager)
                    {
                        parameterID = Action.ChooseParameterGUI("Integer variable:", parameters, parameterID, ParameterType.GlobalVariable);
                        if (parameterID >= 0)
                        {
                            variableID = ShowVarGUI(AdvGame.GetReferences().variablesManager.vars, variableID, false);
                        }
                        else
                        {
                            EditorGUILayout.BeginHorizontal();
                            variableID = ShowVarGUI(AdvGame.GetReferences().variablesManager.vars, variableID, true);
                            if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f)))
                            {
                                SideMenu();
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }
                else if (location == VariableLocation.Local)
                {
                    if (KickStarter.localVariables)
                    {
                        parameterID = Action.ChooseParameterGUI("Integer variable:", parameters, parameterID, ParameterType.LocalVariable);
                        if (parameterID >= 0)
                        {
                            variableID = ShowVarGUI(KickStarter.localVariables.localVars, variableID, false);
                        }
                        else
                        {
                            EditorGUILayout.BeginHorizontal();
                            variableID = ShowVarGUI(KickStarter.localVariables.localVars, variableID, true);
                            if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f)))
                            {
                                SideMenu();
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No 'Local Variables' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info);
                    }
                }
            }
        }
Пример #15
0
        public override void CharSettingsGUI()
        {
                        #if UNITY_EDITOR
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim parameters:", EditorStyles.boldLabel);

            character.spriteChild        = (Transform)EditorGUILayout.ObjectField("Sprite child:", character.spriteChild, typeof(Transform), true);
            character.moveSpeedParameter = EditorGUILayout.TextField("Move speed float:", character.moveSpeedParameter);
            character.turnParameter      = EditorGUILayout.TextField("Turn float:", character.turnParameter);
            character.directionParameter = EditorGUILayout.TextField("Direction integer:", character.directionParameter);
            character.angleParameter     = EditorGUILayout.TextField("Angle float:", character.angleParameter);
            character.talkParameter      = EditorGUILayout.TextField("Talk bool:", character.talkParameter);

            if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager)
            {
                if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
                {
                    character.phonemeParameter = EditorGUILayout.TextField("Phoneme integer:", character.phonemeParameter);
                }
                else if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
                {
                    if (character.GetComponent <LipSyncTexture>() == null)
                    {
                        EditorGUILayout.HelpBox("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
                    }
                }
            }

            if (character.useExpressions)
            {
                character.expressionParameter = EditorGUILayout.TextField("Expression ID integer:", character.expressionParameter);
            }

            character.verticalMovementParameter = EditorGUILayout.TextField("Vertical movement float:", character.verticalMovementParameter);
            character.talkingAnimation          = TalkingAnimation.Standard;
            character.doDirections = true;
            character.doDiagonals  = EditorGUILayout.Toggle("Diagonal sprites?", character.doDiagonals);

            Animator charAnimator = character.GetAnimator();
            if (charAnimator == null || !charAnimator.applyRootMotion)
            {
                character.antiGlideMode = EditorGUILayout.ToggleLeft("Only move when sprite changes?", character.antiGlideMode);
            }

            character.doWallReduction = EditorGUILayout.BeginToggleGroup("Slow movement near wall colliders?", character.doWallReduction);
            character.wallLayer       = EditorGUILayout.TextField("Wall collider layer:", character.wallLayer);
            character.wallDistance    = EditorGUILayout.Slider("Collider distance:", character.wallDistance, 0f, 2f);
            EditorGUILayout.EndToggleGroup();

            if (KickStarter.settingsManager != null && KickStarter.settingsManager.cameraPerspective != CameraPerspective.TwoD)
            {
                character.rotateSprite3D = (RotateSprite3D)EditorGUILayout.EnumPopup("Rotate sprite to:", character.rotateSprite3D);
            }

            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(character);
            }
                        #endif
        }
Пример #16
0
        private void OnGUI()
        {
            if (AdvGame.GetReferences().speechManager == null)
            {
                EditorGUILayout.HelpBox("A Speech Manager must be assigned before this window can display correctly.", MessageType.Warning);
                return;
            }

            scroll = GUILayout.BeginScrollView(scroll);
            SpeechManager speechManager = AdvGame.GetReferences().speechManager;

            EditorGUILayout.HelpBox("Check the settings below and click 'Create' to save a new script sheet.", MessageType.Info);
            EditorGUILayout.Space();

            if (speechManager.languages.Count > 1)
            {
                languageIndex = EditorGUILayout.Popup("Language:", languageIndex, speechManager.languages.ToArray());
            }
            else
            {
                languageIndex = 0;
            }

            limitToCharacter = EditorGUILayout.Toggle("Limit to character?", limitToCharacter);
            if (limitToCharacter)
            {
                characterName = EditorGUILayout.TextField("Character name:", characterName);
            }

            limitToTag = EditorGUILayout.Toggle("Limit by tag?", limitToTag);
            if (limitToTag)
            {
                // Create a string List of the field's names (for the PopUp box)
                List <string> labelList = new List <string>();
                int           i         = 0;
                int           tagNumber = -1;

                if (speechManager.speechTags.Count > 0)
                {
                    foreach (SpeechTag speechTag in speechManager.speechTags)
                    {
                        labelList.Add(speechTag.label);
                        if (speechTag.ID == tagID)
                        {
                            tagNumber = i;
                        }
                        i++;
                    }

                    if (tagNumber == -1)
                    {
                        ACDebug.LogWarning("Previously chosen speech tag no longer exists!");
                        tagNumber = 0;
                        tagID     = 0;
                    }

                    tagNumber = EditorGUILayout.Popup("Speech tag:", tagNumber, labelList.ToArray());
                    tagID     = speechManager.speechTags [tagNumber].ID;
                }
                else
                {
                    EditorGUILayout.HelpBox("No speech tags!", MessageType.Info);
                }
            }

            limitToMissingAudio = EditorGUILayout.Toggle("Limit to lines with no audio?", limitToMissingAudio);

            includeDescriptions = EditorGUILayout.Toggle("Include descriptions?", includeDescriptions);
            removeTokens        = EditorGUILayout.Toggle("Remove text tokens?", removeTokens);

            if (GUILayout.Button("Create"))
            {
                CreateScript();
            }

            EditorGUILayout.Space();
            EditorGUILayout.EndScrollView();
        }
        public static void RefreshActions()
        {
            if (AdvGame.GetReferences() == null || AdvGame.GetReferences().actionsManager == null)
            {
                return;
            }

            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            // Collect data to transfer
            List <ActionType> oldActionTypes = new List <ActionType>();

            foreach (ActionType actionType in actionsManager.AllActions)
            {
                oldActionTypes.Add(actionType);
            }

            actionsManager.AllActions.Clear();

            // Load default Actions
            string        targetDir = "Assets/" + actionsManager.FolderPath;
            DirectoryInfo dir       = new DirectoryInfo(targetDir);

            FileInfo[] info = dir.GetFiles("*.cs");
            foreach (FileInfo f in info)
            {
                try
                {
                    int    extentionPosition = f.Name.IndexOf(".cs");
                    string className         = f.Name.Substring(0, extentionPosition);

                    StreamReader streamReader = new StreamReader(f.FullName);
                    string       fileContents = streamReader.ReadToEnd();
                    streamReader.Close();

                    fileContents = fileContents.Replace(" ", "");

                    if (fileContents.Contains("class" + className + ":Action") ||
                        fileContents.Contains("class" + className + ":AC.Action"))
                    {
                        MonoScript script = AssetDatabase.LoadAssetAtPath <MonoScript> (targetDir + "/" + f.Name);
                        if (script == null)
                        {
                            continue;
                        }

                        Action tempAction = (Action)CreateInstance(script.GetClass());
                        if (tempAction != null && tempAction is Action)
                        {
                            ActionType newActionType = new ActionType(className, tempAction);

                            // Transfer back data
                            foreach (ActionType oldActionType in oldActionTypes)
                            {
                                if (newActionType.IsMatch(oldActionType))
                                {
                                    newActionType.color     = oldActionType.color;
                                    newActionType.isEnabled = oldActionType.isEnabled;
                                    if (newActionType.color == new Color(0f, 0f, 0f, 0f))
                                    {
                                        newActionType.color = Color.white;
                                    }
                                    if (newActionType.color.a < 1f)
                                    {
                                        newActionType.color = new Color(newActionType.color.r, newActionType.color.g, newActionType.color.b, 1f);
                                    }
                                }
                            }

                            actionsManager.AllActions.Add(newActionType);
                        }
                    }
                    else
                    {
                        ACDebug.LogError("The script '" + f.FullName + "' must derive from AC's Action class in order to be available as an Action.");
                    }
                }
                catch {}
            }

            // Load custom Actions
            if (!string.IsNullOrEmpty(actionsManager.customFolderPath) && actionsManager.UsingCustomActionsFolder)
            {
                targetDir = "Assets/" + actionsManager.customFolderPath;
                dir       = new DirectoryInfo(targetDir);

                try
                {
                    info = dir.GetFiles("*.cs");

                    foreach (FileInfo f in info)
                    {
                        try
                        {
                            int    extentionPosition = f.Name.IndexOf(".cs");
                            string className         = f.Name.Substring(0, extentionPosition);

                            StreamReader streamReader = new StreamReader(f.FullName);
                            string       fileContents = streamReader.ReadToEnd();
                            streamReader.Close();

                            fileContents = fileContents.Replace(" ", "");

                            if (fileContents.Contains("class" + className + ":Action") ||
                                fileContents.Contains("class" + className + ":AC.Action"))
                            {
                                MonoScript script = AssetDatabase.LoadAssetAtPath <MonoScript> (targetDir + "/" + f.Name);
                                if (script == null)
                                {
                                    continue;
                                }

                                Action tempAction = (Action)CreateInstance(script.GetClass());
                                if (tempAction != null && tempAction is Action)
                                {
                                    ActionType newActionType = new ActionType(className, tempAction);

                                    // Transfer back data
                                    foreach (ActionType oldActionType in oldActionTypes)
                                    {
                                        if (newActionType.IsMatch(oldActionType))
                                        {
                                            newActionType.color     = oldActionType.color;
                                            newActionType.isEnabled = oldActionType.isEnabled;
                                            if (newActionType.color == new Color(0f, 0f, 0f, 0f))
                                            {
                                                newActionType.color = Color.white;
                                            }
                                            if (newActionType.color.a < 1f)
                                            {
                                                newActionType.color = new Color(newActionType.color.r, newActionType.color.g, newActionType.color.b, 1f);
                                            }
                                        }
                                    }

                                    actionsManager.AllActions.Add(newActionType);
                                }
                            }
                            else
                            {
                                ACDebug.LogError("The script '" + f.FullName + "' must derive from AC's Action class in order to be available as an Action.");
                            }
                        }
                        catch
                        {}
                    }
                }
                catch (System.Exception e)
                {
                    ACDebug.LogWarning("Can't access directory " + "Assets/" + actionsManager.customFolderPath + " - does it exist?\n\nException: " + e);
                }
            }

            actionsManager.AllActions.Sort(delegate(ActionType i1, ActionType i2) { return(i1.GetFullTitle(true).CompareTo(i2.GetFullTitle(true))); });
        }
Пример #18
0
        public override void CharSettingsGUI()
        {
                        #if UNITY_EDITOR
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim parameters", EditorStyles.boldLabel);

            character.moveSpeedParameter = CustomGUILayout.TextField("Move speed float:", character.moveSpeedParameter, "", "The name of the Animator float parameter set to the movement speed");
            character.turnParameter      = CustomGUILayout.TextField("Turn float:", character.turnParameter, "", "The name of the Animator float parameter set to the turning direction");
            character.talkParameter      = CustomGUILayout.TextField("Talk bool:", character.talkParameter, "", "The name of the Animator bool parameter set to True while talking");

            if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager&&
                AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.Off && AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.FaceFX)
            {
                if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
                {
                    character.phonemeParameter = CustomGUILayout.TextField("Phoneme integer:", character.phonemeParameter, "", "The name of the Animator integer parameter set to the lip-syncing phoneme integer");
                    if (character.GetShapeable())
                    {
                        character.lipSyncGroupID = ActionBlendShape.ShapeableGroupGUI("Phoneme shape group:", character.GetShapeable().shapeGroups, character.lipSyncGroupID);
                    }
                }
                else if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
                {
                    if (character.GetComponent <LipSyncTexture>() == null)
                    {
                        EditorGUILayout.HelpBox("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
                    }
                }
            }

            if (!character.ikHeadTurning)
            {
                character.headYawParameter   = CustomGUILayout.TextField("Head yaw float:", character.headYawParameter, "", "The name of the Animator float parameter set to the head yaw");
                character.headPitchParameter = CustomGUILayout.TextField("Head pitch float:", character.headPitchParameter, "", "The name of the Animator float parameter set to the head pitch");
            }

            character.verticalMovementParameter = CustomGUILayout.TextField("Vertical movement float:", character.verticalMovementParameter, "", "The name of the Animator float parameter set to the vertical movement speed");
            character.isGroundedParameter       = CustomGUILayout.TextField("'Is grounded' bool:", character.isGroundedParameter, "", "The name of the Animator boolean parameter set to the 'Is Grounded' check");
            if (character is Player)
            {
                Player player = (Player)character;
                player.jumpParameter = CustomGUILayout.TextField("Jump bool:", player.jumpParameter, "", "The name of the Animator boolean parameter to set to 'True' when jumping");
            }
            character.talkingAnimation = TalkingAnimation.Standard;

            if (character.useExpressions)
            {
                character.expressionParameter = CustomGUILayout.TextField("Expression ID integer:", character.expressionParameter, "", "The name of the Animator integer parameter set to the active Expression ID number");
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim settings", EditorStyles.boldLabel);

            if (SceneSettings.IsTopDown())
            {
                character.spriteChild = (Transform)CustomGUILayout.ObjectField <Transform> ("Animator child:", character.spriteChild, true, "", "The Animator, which should be on a child GameObject");
            }
            else
            {
                character.spriteChild    = null;
                character.customAnimator = (Animator)CustomGUILayout.ObjectField <Animator> ("Animator (optional):", character.customAnimator, true, "", "The Animator, if not on the root GameObject");
            }

            character.headLayer  = CustomGUILayout.IntField("Head layer #:", character.headLayer, "", "The Animator layer used to play head animations while talking");
            character.mouthLayer = CustomGUILayout.IntField("Mouth layer #:", character.mouthLayer, "", "The Animator layer used to play mouth animations while talking");

            character.ikHeadTurning = CustomGUILayout.Toggle("IK head-turning?", character.ikHeadTurning, "", "If True, then inverse-kinematics will be used to turn the character's head dynamically, rather than playing pre-made animations");
            if (character.ikHeadTurning)
            {
                if (character.neckBone == null && character.GetComponent <CapsuleCollider>() == null && character.GetComponent <CharacterController>())
                {
                    EditorGUILayout.HelpBox("For IK head-turning, a 'Neck bone' must be defined, or a Capsule Collider / Character Controller must be placed on this GameObject.", MessageType.Warning);
                }
                character.headIKTurnFactor = CustomGUILayout.Slider("Head-turn factor:", character.headIKTurnFactor, 0f, 1f, "", "How much the head is influenced by IK head-turning.");
                character.bodyIKTurnFactor = CustomGUILayout.Slider("Body-turn factor:", character.bodyIKTurnFactor, 0f, 1f, "", "How much the body is influenced by IK head-turning.");
                character.eyesIKTurnFactor = CustomGUILayout.Slider("Eyes-turn factor:", character.eyesIKTurnFactor, 0f, 1f, "", "How much the eyes is influenced by IK head-turning.");
                                #if UNITY_5 || UNITY_2017_1_OR_NEWER || UNITY_PRO_LICENSE
                EditorGUILayout.HelpBox("'IK Pass' must be enabled for this character's Base layer.", MessageType.Info);
                                #else
                EditorGUILayout.HelpBox("This features is only available with Unity 5 or Unity Pro.", MessageType.Info);
                                #endif
            }

            if (!Application.isPlaying)
            {
                character.ResetAnimator();
            }
            Animator charAnimator = character.GetAnimator();
            if (charAnimator != null && charAnimator.applyRootMotion)
            {
                character.rootTurningFactor = CustomGUILayout.Slider("Root Motion turning:", character.rootTurningFactor, 0f, 1f, "", "The factor by which the job of turning is left to Mecanim root motion");
            }
            character.doWallReduction = CustomGUILayout.Toggle("Slow movement near walls?", character.doWallReduction, "", "If True, then characters will slow down when walking into walls");
            if (character.doWallReduction)
            {
                character.wallLayer    = CustomGUILayout.TextField("Wall collider layer:", character.wallLayer, "", "The layer that walls are expected to be placed on");
                character.wallDistance = CustomGUILayout.Slider("Collider distance:", character.wallDistance, 0f, 2f, "", "The distance to keep away from walls");
                character.wallReductionOnlyParameter = CustomGUILayout.Toggle("Only affects Mecanim parameter?", character.wallReductionOnlyParameter, "", "If True, then the wall reduction factor will only affect the Animator move speed float parameter, and not character's actual speed");
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Bone transforms", EditorStyles.boldLabel);

            character.neckBone      = (Transform)CustomGUILayout.ObjectField <Transform> ("Neck bone:", character.neckBone, true, "", "The 'Neck bone' Transform");
            character.leftHandBone  = (Transform)CustomGUILayout.ObjectField <Transform> ("Left hand:", character.leftHandBone, true, "", "The 'Left hand bone' transform");
            character.rightHandBone = (Transform)CustomGUILayout.ObjectField <Transform> ("Right hand:", character.rightHandBone, true, "", "The 'Right hand bone' transform");
            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(character);
            }
                        #endif
        }
Пример #19
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();
                }
            }
        }
Пример #20
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            if (AdvGame.GetReferences().settingsManager != null && !AdvGame.GetReferences().settingsManager.useProfiles)
            {
                EditorGUILayout.HelpBox("Save game profiles are not enabled - please set in Settings Manager to use this Action.", MessageType.Warning);
                AfterRunningOption();
                return;
            }

            manageProfileType = (ManageProfileType)EditorGUILayout.EnumPopup("Method:", manageProfileType);

            if (manageProfileType == ManageProfileType.CreateProfile)
            {
                useCustomLabel = EditorGUILayout.Toggle("Use custom label?", useCustomLabel);
            }

            if ((manageProfileType == ManageProfileType.CreateProfile && useCustomLabel) || manageProfileType == AC.ManageProfileType.RenameProfile)
            {
                varID = AdvGame.GlobalVariableGUI("Label as String variable:", varID, VariableType.String);
            }

            if (manageProfileType == ManageProfileType.DeleteProfile ||
                manageProfileType == ManageProfileType.RenameProfile ||
                manageProfileType == ManageProfileType.SwitchActiveProfile)
            {
                string _action = "delete";
                if (manageProfileType == ManageProfileType.RenameProfile)
                {
                    _action = "rename";
                }
                else if (manageProfileType == ManageProfileType.SwitchActiveProfile)
                {
                    _action = "switch to";
                }

                deleteProfileType = (DeleteProfileType)EditorGUILayout.EnumPopup("Profile to " + _action + ":", deleteProfileType);
                if (deleteProfileType == DeleteProfileType.SetSlotIndex)
                {
                    profileIndexParameterID = Action.ChooseParameterGUI("Slot index to " + _action + ":", parameters, profileIndexParameterID, ParameterType.Integer);
                    if (profileIndexParameterID == -1)
                    {
                        profileIndex = EditorGUILayout.IntField("Slot index to " + _action + ":", profileIndex);
                    }
                }
                else if (deleteProfileType == DeleteProfileType.SlotIndexFromVariable)
                {
                    slotVarID = AdvGame.GlobalVariableGUI("Integer variable:", slotVarID, VariableType.Integer);
                }
                else if (deleteProfileType == DeleteProfileType.SetProfileID)
                {
                    profileIndexParameterID = Action.ChooseParameterGUI("Profile ID to " + _action + ":", parameters, profileIndexParameterID, ParameterType.Integer);
                    if (profileIndexParameterID == -1)
                    {
                        profileIndex = EditorGUILayout.IntField("Profile ID to " + _action + ":", profileIndex);
                    }
                }
                else if (deleteProfileType == DeleteProfileType.ActiveProfile)
                {
                    if (manageProfileType == ManageProfileType.SwitchActiveProfile)
                    {
                        EditorGUILayout.HelpBox("This combination of fields will no effect - please choose another.", MessageType.Info);
                    }
                }

                if (deleteProfileType == DeleteProfileType.SetSlotIndex ||
                    deleteProfileType == DeleteProfileType.SlotIndexFromVariable)
                {
                    EditorGUILayout.Space();
                    menuName    = EditorGUILayout.TextField("Menu with ProfilesList:", menuName);
                    elementName = EditorGUILayout.TextField("ProfilesList element:", elementName);
                }
            }

            AfterRunningOption();
        }
Пример #21
0
        private int CreateInventoryGUI(int invID)
        {
            if (AdvGame.GetReferences().inventoryManager == null || AdvGame.GetReferences().inventoryManager.items == null || AdvGame.GetReferences().inventoryManager.items.Count == 0)
            {
                EditorGUILayout.HelpBox("Cannot find any inventory items!", MessageType.Warning);
                return(invID);
            }

            // Create a string List of the field's names (for the PopUp box)
            List <string> labelList = new List <string>();
            int           invNumber = -1;
            int           i         = 0;

            if (AdvGame.GetReferences().inventoryManager.items.Count > 0)
            {
                foreach (InvItem _item in AdvGame.GetReferences().inventoryManager.items)
                {
                    labelList.Add(_item.label);

                    // If a item has been removed, make sure selected variable is still valid
                    if (_item.id == invID)
                    {
                        invNumber = i;
                    }
                    i++;
                }

                if (invNumber == -1)
                {
                    if (invID > 0)
                    {
                        ACDebug.Log("Previously chosen item no longer exists!");
                    }
                    invNumber = 0;
                    invID     = 0;
                }
                else
                {
                    invNumber = CustomGUILayout.Popup("Linked inventory item:", invNumber, labelList.ToArray(), "", "The inventory item that the player must be carrying for the option to be active");
                    invID     = AdvGame.GetReferences().inventoryManager.items[invNumber].id;
                }
            }

            return(invID);
        }
Пример #22
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 (speechManager == null || exportColumns == null || exportColumns.Count == 0 || speechManager.lines == null || speechManager.lines.Count == 0)
            {
                return;
            }

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

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

            string[]          sceneNames  = speechManager.GetSceneNames();
            List <SpeechLine> exportLines = new List <SpeechLine>();
            foreach (SpeechLine line in speechManager.lines)
            {
                if (filterByType)
                {
                    if (line.textType != typeFilter)
                    {
                        continue;
                    }
                }
                if (filterByScene)
                {
                    if (sceneNames != null && sceneNames.Length > sceneFilter)
                    {
                        string selectedScene      = sceneNames[sceneFilter] + ".unity";
                        string scenePlusExtension = (line.scene != "") ? (line.scene + ".unity") : "";

                        if ((line.scene == "" && sceneFilter == 0) ||
                            sceneFilter == 1 ||
                            (line.scene != "" && sceneFilter > 1 && line.scene.EndsWith(selectedScene)) ||
                            (line.scene != "" && sceneFilter > 1 && scenePlusExtension.EndsWith(selectedScene)))
                        {
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
                if (filterByText)
                {
                    if (!line.Matches(textFilter, filterSpeechLine))
                    {
                        continue;
                    }
                }
                if (filterByTag)
                {
                    if (tagFilter == -1 ||
                        (tagFilter < speechManager.speechTags.Count && line.tagID == speechManager.speechTags[tagFilter].ID))
                    {
                    }
                    else
                    {
                        continue;
                    }
                }

                exportLines.Add(new SpeechLine(line));
            }

            if (doRowSorting)
            {
                if (rowSorting == RowSorting.ByID)
                {
                    exportLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.lineID.CompareTo(b.lineID)); });
                }
                else if (rowSorting == RowSorting.ByDescription)
                {
                    exportLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.description.CompareTo(b.description)); });
                }
                else if (rowSorting == RowSorting.ByType)
                {
                    exportLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.textType.ToString().CompareTo(b.textType.ToString())); });
                }
                else if (rowSorting == RowSorting.ByAssociatedObject)
                {
                    exportLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.owner.CompareTo(b.owner)); });
                }
                else if (rowSorting == RowSorting.ByScene)
                {
                    exportLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.scene.CompareTo(b.owner)); });
                }
            }

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

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

            foreach (SpeechLine line in exportLines)
            {
                List <string> rowList = new List <string>();
                rowList.Add(line.lineID.ToString());
                foreach (ExportColumn exportColumn in exportColumns)
                {
                    string cellText = exportColumn.GetCellText(line);
                    rowList.Add(cellText);

                    if (cellText.Contains(CSVReader.csvDelimiter))
                    {
                        fail = true;
                        ACDebug.LogError("Cannot export translation since line " + line.lineID.ToString() + " (" + line.text + ") contains the character '" + CSVReader.csvDelimiter + "'.");
                    }
                }
                output.Add(rowList.ToArray());
            }

            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((exportLines.Count - 1).ToString() + " lines exported.");
                }
            }

            //this.Close ();
                        #endif
        }
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            if (inventoryManager == null && AdvGame.GetReferences().inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences().inventoryManager;
            }
            if (settingsManager == null && AdvGame.GetReferences().settingsManager)
            {
                settingsManager = AdvGame.GetReferences().settingsManager;
            }

            invCheckType = (InvCheckType)EditorGUILayout.EnumPopup("Check to make:", invCheckType);
            if (invCheckType == InvCheckType.NumberOfItemsCarrying)
            {
                intCondition = (IntCondition)EditorGUILayout.EnumPopup("Count is:", intCondition);

                intValueParameterID = Action.ChooseParameterGUI(intCondition.ToString() + ":", parameters, intValueParameterID, ParameterType.Integer);
                if (intValueParameterID < 0)
                {
                    intValue = EditorGUILayout.IntField(intCondition.ToString() + ":", intValue);
                }

                if (inventoryManager != null && inventoryManager.bins != null && inventoryManager.bins.Count > 0)
                {
                    checkNumberInCategory = EditorGUILayout.Toggle("Check specific category?", checkNumberInCategory);
                    if (checkNumberInCategory)
                    {
                        int      categoryIndex = 0;
                        string[] popupList     = new string[inventoryManager.bins.Count];
                        for (int i = 0; i < inventoryManager.bins.Count; i++)
                        {
                            popupList[i] = inventoryManager.bins[i].label;

                            if (inventoryManager.bins[i].id == categoryIDToCheck)
                            {
                                categoryIndex = i;
                            }
                        }

                        categoryIndex     = EditorGUILayout.Popup("Limit to category:", categoryIndex, popupList);
                        categoryIDToCheck = inventoryManager.bins[categoryIndex].id;
                    }
                }

                SetPlayerGUI();
                return;
            }

            if (inventoryManager)
            {
                // Create a string List of the field's names (for the PopUp box)
                List <string> labelList = new List <string>();

                int i = 0;
                if (parameterID == -1)
                {
                    invNumber = -1;
                }

                if (inventoryManager.items.Count > 0)
                {
                    foreach (InvItem _item in inventoryManager.items)
                    {
                        labelList.Add(_item.label);

                        // If an item has been removed, make sure selected variable is still valid
                        if (_item.id == invID)
                        {
                            invNumber = i;
                        }

                        i++;
                    }

                    if (invNumber == -1)
                    {
                        // Wasn't found (item was possibly deleted), so revert to zero
                        ACDebug.LogWarning("Previously chosen item no longer exists!");

                        invNumber = 0;
                        invID     = 0;
                    }

                    //
                    parameterID = Action.ChooseParameterGUI("Inventory item:", parameters, parameterID, ParameterType.InventoryItem);
                    if (parameterID >= 0)
                    {
                        invNumber = Mathf.Min(invNumber, inventoryManager.items.Count - 1);
                        invID     = -1;
                    }
                    else
                    {
                        invNumber = EditorGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray());
                        invID     = inventoryManager.items[invNumber].id;
                    }
                    //

                    if (inventoryManager.items[invNumber].canCarryMultiple)
                    {
                        doCount = EditorGUILayout.Toggle("Query count?", doCount);

                        if (doCount)
                        {
                            intCondition        = (IntCondition)EditorGUILayout.EnumPopup("Count is:", intCondition);
                            intValueParameterID = Action.ChooseParameterGUI(intCondition.ToString() + ":", parameters, intValueParameterID, ParameterType.Integer);
                            if (intValueParameterID < 0)
                            {
                                intValue = EditorGUILayout.IntField(intCondition.ToString() + ":", intValue);

                                if (intValue < 1)
                                {
                                    intValue = 1;
                                }
                            }
                        }
                    }
                    else
                    {
                        doCount = false;
                    }

                    SetPlayerGUI();
                }
                else
                {
                    EditorGUILayout.LabelField("No inventory items exist!");
                    invID     = -1;
                    invNumber = -1;
                }
            }
            else
            {
                EditorGUILayout.HelpBox("An Inventory Manager must be assigned for this Action to work", MessageType.Warning);
            }
        }
        /**
         * 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.");
            }
        }
Пример #25
0
        private int ShowVarGUI(List <ActionParameter> parameters, List <GVar> _vars, int ID, bool changeID)
        {
            VariableType showType = VariableType.Boolean;

            if (changeID)
            {
                if (_vars != null && _vars.Count > 0)
                {
                    ID = ShowVarSelectorGUI(_vars, ID, "Variable:");

                    variableNumber = Mathf.Min(variableNumber, _vars.Count - 1);
                    getVarMethod   = (GetVarMethod)EditorGUILayout.EnumPopup("Compare with:", getVarMethod);

                    showType = _vars[variableNumber].type;
                }
                else
                {
                    EditorGUILayout.HelpBox("No variables exist!", MessageType.Info);
                    ID             = -1;
                    variableNumber = -1;
                    return(ID);
                }
            }
            else
            {
                showType = placeholderType;
            }

            switch (showType)
            {
            case VariableType.Boolean:
                boolCondition = (BoolCondition)EditorGUILayout.EnumPopup("Condition:", boolCondition);
                if (getVarMethod == GetVarMethod.EnteredValue)
                {
                    checkParameterID = Action.ChooseParameterGUI("Boolean:", parameters, checkParameterID, ParameterType.Boolean);
                    if (checkParameterID < 0)
                    {
                        boolValue = (BoolValue)EditorGUILayout.EnumPopup("Boolean:", boolValue);
                    }
                }
                break;

            case VariableType.Integer:
                intCondition = (IntCondition)EditorGUILayout.EnumPopup("Condition:", intCondition);
                if (getVarMethod == GetVarMethod.EnteredValue)
                {
                    checkParameterID = Action.ChooseParameterGUI("Integer:", parameters, checkParameterID, ParameterType.Integer);
                    if (checkParameterID < 0)
                    {
                        intValue = EditorGUILayout.IntField("Integer:", intValue);
                    }
                }
                break;

            case VariableType.Float:
                intCondition = (IntCondition)EditorGUILayout.EnumPopup("Condition:", intCondition);
                if (getVarMethod == GetVarMethod.EnteredValue)
                {
                    checkParameterID = Action.ChooseParameterGUI("Float:", parameters, checkParameterID, ParameterType.Float);
                    if (checkParameterID < 0)
                    {
                        floatValue = EditorGUILayout.FloatField("Float:", floatValue);
                    }
                }
                break;

            case VariableType.PopUp:
                intCondition = (IntCondition)EditorGUILayout.EnumPopup("Condition:", intCondition);
                if (getVarMethod == GetVarMethod.EnteredValue)
                {
                    checkParameterID = Action.ChooseParameterGUI("Value:", parameters, checkParameterID, ParameterType.Integer);
                    if (checkParameterID < 0)
                    {
                        if (changeID && _vars != null && _vars.Count > variableNumber)
                        {
                            string[] popUpLabels = _vars[variableNumber].GenerateEditorPopUpLabels();
                            intValue = EditorGUILayout.Popup("Value:", intValue, popUpLabels);
                        }
                        else
                        {
                            intValue = EditorGUILayout.IntField("Index value:", intValue);
                        }
                    }
                }
                break;

            case VariableType.String:
                boolCondition = (BoolCondition)EditorGUILayout.EnumPopup("Condition:", boolCondition);
                if (getVarMethod == GetVarMethod.EnteredValue)
                {
                    checkParameterID = Action.ChooseParameterGUI("String:", parameters, checkParameterID, ParameterType.String);
                    if (checkParameterID < 0)
                    {
                        stringValue = EditorGUILayout.TextField("String:", stringValue);
                    }
                }
                checkCase = EditorGUILayout.Toggle("Case-senstive?", checkCase);
                break;

            case VariableType.Vector3:
                vectorCondition = (VectorCondition)EditorGUILayout.EnumPopup("Condition:", vectorCondition);
                if (getVarMethod == GetVarMethod.EnteredValue)
                {
                    if (vectorCondition == VectorCondition.MagnitudeGreaterThan)
                    {
                        checkParameterID = Action.ChooseParameterGUI("Float:", parameters, checkParameterID, ParameterType.Float);
                        if (checkParameterID < 0)
                        {
                            floatValue = EditorGUILayout.FloatField("Float:", floatValue);
                        }
                    }
                    else if (vectorCondition == VectorCondition.EqualTo)
                    {
                        checkParameterID = Action.ChooseParameterGUI("Vector3:", parameters, checkParameterID, ParameterType.Vector3);
                        if (checkParameterID < 0)
                        {
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("Vector3:", GUILayout.MaxWidth(60f));
                            vector3Value = EditorGUILayout.Vector3Field("", vector3Value);
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }
                break;

            default:
                break;
            }

            if (getVarMethod == GetVarMethod.GlobalVariable)
            {
                if (AdvGame.GetReferences().variablesManager == null || AdvGame.GetReferences().variablesManager.vars == null || AdvGame.GetReferences().variablesManager.vars.Count == 0)
                {
                    EditorGUILayout.HelpBox("No Global variables exist!", MessageType.Info);
                }
                else
                {
                    checkParameterID = Action.ChooseParameterGUI("Global variable:", parameters, checkParameterID, ParameterType.GlobalVariable);
                    if (checkParameterID < 0)
                    {
                        compareVariableID = ShowVarSelectorGUI(AdvGame.GetReferences().variablesManager.vars, compareVariableID, "Global variable:");
                    }
                }
            }
            else if (getVarMethod == GetVarMethod.LocalVariable)
            {
                if (localVariables == null || localVariables.localVars == null || localVariables.localVars.Count == 0)
                {
                    EditorGUILayout.HelpBox("No Local variables exist!", MessageType.Info);
                }
                else
                {
                    checkParameterID = Action.ChooseParameterGUI("Local variable:", parameters, checkParameterID, ParameterType.LocalVariable);
                    if (checkParameterID < 0)
                    {
                        compareVariableID = ShowVarSelectorGUI(localVariables.localVars, compareVariableID, "Local variable:");
                    }
                }
            }
            else if (getVarMethod == GetVarMethod.ComponentVariable)
            {
                checkParameterID = Action.ChooseParameterGUI("Component variable:", parameters, checkParameterID, ParameterType.ComponentVariable);
                if (checkParameterID < 0)
                {
                    compareVariables           = (Variables)EditorGUILayout.ObjectField("Component", compareVariables, typeof(Variables), true);
                    compareVariablesConstantID = FieldToID <Variables> (compareVariables, compareVariablesConstantID);
                    compareVariables           = IDToField <Variables> (compareVariables, compareVariablesConstantID, false);

                    if (compareVariables != null)
                    {
                        compareVariableID = ShowVarSelectorGUI(compareVariables.vars, compareVariableID, "Component variable:");
                    }
                }
            }

            return(ID);
        }
Пример #26
0
        private void SetParamGUI(List <ActionParameter> parameters, List <ActionParameter> ownParameters = null)
        {
            if (parameters == null || parameters.Count == 0)
            {
                parameterLabel = "";
                return;
            }

            _parameter = GetParameterWithID(parameters, parameterID);

            if (_parameter == null)
            {
                parameterLabel = "";
                return;
            }

            parameterLabel = _parameter.label;

            setParamMethod = (SetParamMethod)EditorGUILayout.EnumPopup("New value is:", setParamMethod);

            if (setParamMethod == SetParamMethod.EnteredHere)
            {
                if (ownParameters != null && ownParameters.Count > 0)
                {
                    ownParamID = Action.ChooseParameterGUI("Set as:", ownParameters, ownParamID, _parameter.parameterType);
                    if (ownParamID >= 0)
                    {
                        return;
                    }
                }

                if (_parameter.parameterType == ParameterType.Boolean)
                {
                    bool boolValue = (intValue == 1) ? true : false;
                    boolValue = EditorGUILayout.Toggle("Set as:", boolValue);
                    intValue  = (boolValue) ? 1 : 0;
                }
                else if (_parameter.parameterType == ParameterType.Integer)
                {
                    intValue = EditorGUILayout.IntField("Set as:", intValue);
                }
                else if (_parameter.parameterType == ParameterType.Float)
                {
                    floatValue = EditorGUILayout.FloatField("Set as:", floatValue);
                }
                else if (_parameter.parameterType == ParameterType.String)
                {
                    stringValue = EditorGUILayout.TextField("Set as:", stringValue);
                }
                else if (_parameter.parameterType == ParameterType.GameObject)
                {
                    gameobjectValue = (GameObject)EditorGUILayout.ObjectField("Set to:", gameobjectValue, typeof(GameObject), true);

                    gameObjectConstantID = FieldToID(gameobjectValue, gameObjectConstantID);
                    gameobjectValue      = IDToField(gameobjectValue, gameObjectConstantID, false);
                }
                else if (_parameter.parameterType == ParameterType.GlobalVariable)
                {
                    if (AdvGame.GetReferences().variablesManager == null || AdvGame.GetReferences().variablesManager.vars == null || AdvGame.GetReferences().variablesManager.vars.Count == 0)
                    {
                        EditorGUILayout.HelpBox("No Global variables exist!", MessageType.Info);
                    }
                    else
                    {
                        intValue = ShowVarSelectorGUI(AdvGame.GetReferences().variablesManager.vars, intValue);
                    }
                }
                else if (_parameter.parameterType == ParameterType.UnityObject)
                {
                    unityObjectValue = (Object)EditorGUILayout.ObjectField("Set to:", unityObjectValue, typeof(Object), true);
                }
                else if (_parameter.parameterType == ParameterType.InventoryItem)
                {
                    intValue = ShowInvSelectorGUI(intValue);
                }
                else if (_parameter.parameterType == ParameterType.LocalVariable)
                {
                    if (isAssetFile)
                    {
                        EditorGUILayout.HelpBox("Cannot access local variables from an asset file.", MessageType.Warning);
                    }
                    else if (KickStarter.localVariables == null || KickStarter.localVariables.localVars == null || KickStarter.localVariables.localVars.Count == 0)
                    {
                        EditorGUILayout.HelpBox("No Local variables exist!", MessageType.Info);
                    }
                    else
                    {
                        intValue = ShowVarSelectorGUI(KickStarter.localVariables.localVars, intValue);
                    }
                }
                else if (_parameter.parameterType == ParameterType.Vector3)
                {
                    vector3Value = EditorGUILayout.Vector3Field("Set as:", vector3Value);
                }
            }
            else if (setParamMethod == SetParamMethod.Random)
            {
                if (_parameter.parameterType == ParameterType.Boolean)
                {
                }
                else if (_parameter.parameterType == ParameterType.Integer)
                {
                    intValue    = EditorGUILayout.IntField("Minimum:", intValue);
                    intValueMax = EditorGUILayout.IntField("Maximum:", intValueMax);
                    if (intValueMax < intValue)
                    {
                        intValueMax = intValue;
                    }
                }
                else if (_parameter.parameterType == ParameterType.Float)
                {
                    floatValue    = EditorGUILayout.FloatField("Minimum:", floatValue);
                    floatValueMax = EditorGUILayout.FloatField("Maximum:", floatValueMax);
                    if (floatValueMax < floatValue)
                    {
                        floatValueMax = floatValue;
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Parameters of type '" + _parameter.parameterType + "' cannot be set randomly.", MessageType.Warning);
                }
            }
            else if (setParamMethod == SetParamMethod.CopiedFromGlobalVariable)
            {
                if (AdvGame.GetReferences() != null && AdvGame.GetReferences().variablesManager != null && AdvGame.GetReferences().variablesManager.vars != null && AdvGame.GetReferences().variablesManager.vars.Count > 0)
                {
                    if (_parameter.parameterType == ParameterType.Vector3)
                    {
                        globalVariableID = AdvGame.GlobalVariableGUI("Vector3 variable:", globalVariableID, VariableType.Vector3);
                    }
                    else if (_parameter.parameterType == ParameterType.GameObject || _parameter.parameterType == ParameterType.GlobalVariable || _parameter.parameterType == ParameterType.InventoryItem || _parameter.parameterType == ParameterType.LocalVariable || _parameter.parameterType == ParameterType.UnityObject)
                    {
                        EditorGUILayout.HelpBox("Parameters of type '" + _parameter.parameterType + "' cannot have values transferred from Global Variables.", MessageType.Warning);
                    }
                    else
                    {
                        globalVariableID = AdvGame.GlobalVariableGUI("Variable:", globalVariableID);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("No Global Variables found!", MessageType.Warning);
                }
            }
            else if (setParamMethod == SetParamMethod.CopiedFromParameter)
            {
                if (changeOwn)
                {
                    parameterToCopyID = Action.ChooseParameterGUI(parameters, parameterToCopyID);
                }
                else
                {
                    if (actionListSource == ActionListSource.InScene && actionList != null)
                    {
                        if (actionList.source == ActionListSource.InScene)
                        {
                            if (actionList.useParameters && actionList.parameters.Count > 0)
                            {
                                parameterToCopyID = Action.ChooseParameterGUI(actionList.parameters, parameterToCopyID);
                            }
                        }
                        else if (actionList.source == ActionListSource.AssetFile && actionList.assetFile != null)
                        {
                            if (actionList.assetFile.useParameters && actionList.assetFile.parameters.Count > 0)
                            {
                                parameterToCopyID = Action.ChooseParameterGUI(actionList.assetFile.parameters, parameterToCopyID);
                            }
                        }
                    }
                    else if (actionListSource == ActionListSource.AssetFile && actionListAsset != null)
                    {
                        if (actionListAsset.useParameters && actionListAsset.parameters.Count > 0)
                        {
                            parameterToCopyID = Action.ChooseParameterGUI(actionListAsset.parameters, parameterToCopyID);
                        }
                    }
                }
            }
        }
Пример #27
0
        public void ShowGUI()
        {
            GUILayout.Label("Basic structure", EditorStyles.boldLabel);

            if (GUILayout.Button("Organise room objects"))
            {
                InitialiseObjects();
            }

            if (AdvGame.GetReferences().settingsManager == null)
            {
                EditorGUILayout.HelpBox("No Settings Manager defined - cannot display full Editor without it!", MessageType.Warning);
                return;
            }

            if (KickStarter.sceneSettings == null)
            {
                return;
            }

            SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;

            EditorGUILayout.BeginHorizontal();
            newFolderName = EditorGUILayout.TextField(newFolderName);

            if (GUILayout.Button("Create new folder", buttonWidth))
            {
                if (newFolderName != "")
                {
                    GameObject newFolder = new GameObject();

                    if (!newFolderName.StartsWith("_"))
                    {
                        newFolder.name = "_" + newFolderName;
                    }
                    else
                    {
                        newFolder.name = newFolderName;
                    }

                    Undo.RegisterCreatedObjectUndo(newFolder, "Create folder " + newFolder.name);

                    if (Selection.activeGameObject)
                    {
                        newFolder.transform.parent = Selection.activeGameObject.transform;
                    }

                    Selection.activeObject = newFolder;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            GUILayout.Label("Scene settings", EditorStyles.boldLabel);
            KickStarter.sceneSettings.navigationMethod = (AC_NavigationMethod)EditorGUILayout.EnumPopup("Pathfinding method:", KickStarter.sceneSettings.navigationMethod);
            KickStarter.navigationManager.ResetEngine();
            if (KickStarter.navigationManager.navigationEngine != null)
            {
                KickStarter.navigationManager.navigationEngine.SceneSettingsGUI();
            }

            if (settingsManager.IsUnity2D() && KickStarter.sceneSettings.navigationMethod != AC_NavigationMethod.PolygonCollider)
            {
                EditorGUILayout.HelpBox("This pathfinding method is not compatible with 'Unity 2D'.", MessageType.Warning);
            }

            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.defaultPlayerStart = (PlayerStart)EditorGUILayout.ObjectField("Default PlayerStart:", KickStarter.sceneSettings.defaultPlayerStart, typeof(PlayerStart), true);
            if (KickStarter.sceneSettings.defaultPlayerStart == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    PlayerStart newPlayerStart = AddPrefab("Navigation", "PlayerStart", true, false, true).GetComponent <PlayerStart>();
                    newPlayerStart.gameObject.name = "Default PlayerStart";
                    KickStarter.sceneSettings.defaultPlayerStart = newPlayerStart;
                }
            }
            EditorGUILayout.EndHorizontal();
            if (KickStarter.sceneSettings.defaultPlayerStart)
            {
                EditorGUILayout.BeginHorizontal();
                KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart = (_Camera)EditorGUILayout.ObjectField("Default Camera:", KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart, typeof(_Camera), true);
                if (KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart == null)
                {
                    if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                    {
                        if (settingsManager == null || settingsManager.cameraPerspective == CameraPerspective.ThreeD)
                        {
                            GameCamera newCamera = AddPrefab("Camera", "GameCamera", true, false, true).GetComponent <GameCamera>();
                            newCamera.gameObject.name = "NavCam 1";
                            KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart = newCamera;
                        }
                        else if (settingsManager.cameraPerspective == CameraPerspective.TwoD)
                        {
                            GameCamera2D newCamera = AddPrefab("Camera", "GameCamera2D", true, false, true).GetComponent <GameCamera2D>();
                            newCamera.gameObject.name = "NavCam 1";
                            KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart = newCamera;
                        }
                        else if (settingsManager.cameraPerspective == CameraPerspective.TwoPointFiveD)
                        {
                            GameCamera25D newCamera = AddPrefab("Camera", "GameCamera2.5D", true, false, true).GetComponent <GameCamera25D>();
                            newCamera.gameObject.name = "NavCam 1";
                            KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart = newCamera;
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.sortingMap = (SortingMap)EditorGUILayout.ObjectField("Default Sorting map:", KickStarter.sceneSettings.sortingMap, typeof(SortingMap), true);
            if (KickStarter.sceneSettings.sortingMap == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    SortingMap newSortingMap = AddPrefab("Navigation", "SortingMap", true, false, true).GetComponent <SortingMap>();
                    newSortingMap.gameObject.name        = "Default SortingMap";
                    KickStarter.sceneSettings.sortingMap = newSortingMap;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.defaultSound = (Sound)EditorGUILayout.ObjectField("Default Sound prefab:", KickStarter.sceneSettings.defaultSound, typeof(Sound), true);
            if (KickStarter.sceneSettings.defaultSound == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Sound newSound = AddPrefab("Logic", "Sound", true, false, true).GetComponent <Sound>();
                    newSound.gameObject.name = "Default Sound";
                    KickStarter.sceneSettings.defaultSound = newSound;
                    newSound.playWhilePaused = true;
                }
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Label("Scene cutscenes", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.cutsceneOnStart = (Cutscene)EditorGUILayout.ObjectField("On start:", KickStarter.sceneSettings.cutsceneOnStart, typeof(Cutscene), true);
            if (KickStarter.sceneSettings.cutsceneOnStart == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Cutscene newCutscene = AddPrefab("Logic", "Cutscene", true, false, true).GetComponent <Cutscene>();
                    newCutscene.gameObject.name = "OnStart";
                    KickStarter.sceneSettings.cutsceneOnStart = newCutscene;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.cutsceneOnLoad = (Cutscene)EditorGUILayout.ObjectField("On load:", KickStarter.sceneSettings.cutsceneOnLoad, typeof(Cutscene), true);
            if (KickStarter.sceneSettings.cutsceneOnLoad == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Cutscene newCutscene = AddPrefab("Logic", "Cutscene", true, false, true).GetComponent <Cutscene>();
                    newCutscene.gameObject.name = "OnLoad";
                    KickStarter.sceneSettings.cutsceneOnLoad = newCutscene;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.cutsceneOnVarChange = (Cutscene)EditorGUILayout.ObjectField("On variable change:", KickStarter.sceneSettings.cutsceneOnVarChange, typeof(Cutscene), true);
            if (KickStarter.sceneSettings.cutsceneOnVarChange == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Cutscene newCutscene = AddPrefab("Logic", "Cutscene", true, false, true).GetComponent <Cutscene>();
                    newCutscene.gameObject.name = "OnVarChange";
                    KickStarter.sceneSettings.cutsceneOnVarChange = newCutscene;
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.Label("Visibility", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Triggers", buttonWidth);
            if (GUILayout.Button("On", EditorStyles.miniButtonLeft))
            {
                SetTriggerVisibility(true);
            }
            if (GUILayout.Button("Off", EditorStyles.miniButtonRight))
            {
                SetTriggerVisibility(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Collision", buttonWidth);
            if (GUILayout.Button("On", EditorStyles.miniButtonLeft))
            {
                SetCollisionVisiblity(true);
            }
            if (GUILayout.Button("Off", EditorStyles.miniButtonRight))
            {
                SetCollisionVisiblity(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Hotspots", buttonWidth);
            if (GUILayout.Button("On", EditorStyles.miniButtonLeft))
            {
                SetHotspotVisibility(true);
            }
            if (GUILayout.Button("Off", EditorStyles.miniButtonRight))
            {
                SetHotspotVisibility(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("NavMesh", buttonWidth);
            if (GUILayout.Button("On", EditorStyles.miniButtonLeft))
            {
                KickStarter.navigationManager.navigationEngine.SetVisibility(true);
            }
            if (GUILayout.Button("Off", EditorStyles.miniButtonRight))
            {
                KickStarter.navigationManager.navigationEngine.SetVisibility(false);
            }
            GUILayout.EndHorizontal();

            ListPrefabs();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(KickStarter.sceneSettings);
                EditorUtility.SetDirty(KickStarter.playerMovement);
                if (KickStarter.sceneSettings.defaultPlayerStart)
                {
                    EditorUtility.SetDirty(KickStarter.sceneSettings.defaultPlayerStart);
                }
            }
        }
Пример #28
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            // OLD

            oldLocation = (VariableLocation)EditorGUILayout.EnumPopup("'From' source:", oldLocation);

            switch (oldLocation)
            {
            case VariableLocation.Global:
                if (AdvGame.GetReferences().variablesManager != null)
                {
                    oldVariableID = ShowVarGUI(AdvGame.GetReferences().variablesManager.vars, parameters, ParameterType.GlobalVariable, oldVariableID, oldParameterID, false);
                }
                break;

            case VariableLocation.Local:
                if (isAssetFile)
                {
                    EditorGUILayout.HelpBox("Local variables cannot be accessed in ActionList assets.", MessageType.Info);
                }
                else if (localVariables != null)
                {
                    oldVariableID = ShowVarGUI(localVariables.localVars, parameters, ParameterType.LocalVariable, oldVariableID, oldParameterID, false);
                }
                else
                {
                    EditorGUILayout.HelpBox("No 'Local Variables' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info);
                }
                break;

            case VariableLocation.Component:
                oldParameterID = Action.ChooseParameterGUI("'From' variable:", parameters, oldParameterID, ParameterType.ComponentVariable);
                if (oldParameterID >= 0)
                {
                    oldVariables           = null;
                    oldVariablesConstantID = 0;
                }
                else
                {
                    oldVariables = (Variables)EditorGUILayout.ObjectField("'Old' component:", oldVariables, typeof(Variables), true);
                    if (oldVariables != null)
                    {
                        oldVariableID = ShowVarGUI(oldVariables.vars, null, ParameterType.ComponentVariable, oldVariableID, oldParameterID, false);
                    }

                    oldVariablesConstantID = FieldToID <Variables> (oldVariables, oldVariablesConstantID);
                    oldVariables           = IDToField <Variables> (oldVariables, oldVariablesConstantID, false);
                }
                break;
            }

            EditorGUILayout.Space();

            // NEW

            newLocation = (VariableLocation)EditorGUILayout.EnumPopup("'To' source:", newLocation);

            switch (newLocation)
            {
            case VariableLocation.Global:
                if (AdvGame.GetReferences().variablesManager != null)
                {
                    newVariableID = ShowVarGUI(AdvGame.GetReferences().variablesManager.vars, parameters, ParameterType.GlobalVariable, newVariableID, newParameterID, true);
                }
                break;

            case VariableLocation.Local:
                if (isAssetFile)
                {
                    EditorGUILayout.HelpBox("Local variables cannot be accessed in ActionList assets.", MessageType.Info);
                }
                else if (localVariables != null)
                {
                    newVariableID = ShowVarGUI(localVariables.localVars, parameters, ParameterType.LocalVariable, newVariableID, newParameterID, true);
                }
                else
                {
                    EditorGUILayout.HelpBox("No 'Local Variables' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info);
                }
                break;

            case VariableLocation.Component:
                newParameterID = Action.ChooseParameterGUI("'To' variable:", parameters, newParameterID, ParameterType.ComponentVariable);
                if (newParameterID >= 0)
                {
                    newVariables           = null;
                    newVariablesConstantID = 0;
                }
                else
                {
                    newVariables = (Variables)EditorGUILayout.ObjectField("'New' component:", newVariables, typeof(Variables), true);
                    if (newVariables != null)
                    {
                        newVariableID = ShowVarGUI(oldVariables.vars, null, ParameterType.ComponentVariable, newVariableID, newParameterID, false);
                    }

                    newVariablesConstantID = FieldToID <Variables> (newVariables, newVariablesConstantID);
                    newVariables           = IDToField <Variables> (newVariables, newVariablesConstantID, false);
                }
                break;
            }

            // Types match?
            if (oldParameterID == -1 && newParameterID == -1 && newVarType != oldVarType)
            {
                EditorGUILayout.HelpBox("The chosen Variables do not share the same Type - a conversion will be attemped", MessageType.Info);
            }

            AfterRunningOption();
        }
Пример #29
0
        public static void RefreshActions()
        {
            if (AdvGame.GetReferences() == null || AdvGame.GetReferences().actionsManager == null)
            {
                return;
            }

            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            // Collect data to transfer
            List <ActionType> oldActionTypes = new List <ActionType>();

            foreach (ActionType actionType in actionsManager.AllActions)
            {
                oldActionTypes.Add(actionType);
            }

            // Load default Actions
            DirectoryInfo dir = new DirectoryInfo("Assets/" + actionsManager.folderPath);

            FileInfo[] info = dir.GetFiles("*.cs");

            actionsManager.AllActions.Clear();
            foreach (FileInfo f in info)
            {
                try
                {
                    int    extentionPosition = f.Name.IndexOf(".cs");
                    string className         = f.Name.Substring(0, extentionPosition);

                    StreamReader streamReader = new StreamReader(f.FullName);
                    string       fileContents = streamReader.ReadToEnd();
                    streamReader.Close();

                    fileContents = fileContents.Replace(" ", "");

                    if (fileContents.Contains("class" + className + ":Action") ||
                        fileContents.Contains("class" + className + ":AC.Action"))
                    {
                        Action tempAction = (Action)CreateInstance(className);
                        if (tempAction is Action)
                        {
                            ActionType newActionType = new ActionType(className, tempAction);

                            // Transfer back data
                            foreach (ActionType oldActionType in oldActionTypes)
                            {
                                if (newActionType.IsMatch(oldActionType))
                                {
                                    newActionType.color = oldActionType.color;
                                    if (newActionType.color == new Color(0f, 0f, 0f, 0f))
                                    {
                                        newActionType.color = Color.white;
                                    }
                                    if (newActionType.color.a < 1f)
                                    {
                                        newActionType.color = new Color(newActionType.color.r, newActionType.color.g, newActionType.color.b, 1f);
                                    }
                                }
                            }

                            actionsManager.AllActions.Add(newActionType);
                        }
                    }
                    else
                    {
                        ACDebug.LogError("The script '" + f.FullName + "' must derive from AC's Action class in order to be available as an Action.");
                    }
                }
                catch {}
            }

            // Load custom Actions
            if (!string.IsNullOrEmpty(actionsManager.customFolderPath) && actionsManager.customFolderPath != actionsManager.folderPath)
            {
                dir  = new DirectoryInfo("Assets/" + actionsManager.customFolderPath);
                info = dir.GetFiles("*.cs");

                foreach (FileInfo f in info)
                {
                    try
                    {
                        int    extentionPosition = f.Name.IndexOf(".cs");
                        string className         = f.Name.Substring(0, extentionPosition);

                        StreamReader streamReader = new StreamReader(f.FullName);
                        string       fileContents = streamReader.ReadToEnd();
                        streamReader.Close();

                        fileContents = fileContents.Replace(" ", "");

                        if (fileContents.Contains("class" + className + ":Action") ||
                            fileContents.Contains("class" + className + ":AC.Action"))
                        {
                            Action tempAction = (Action)CreateInstance(className);
                            if (tempAction is Action)
                            {
                                actionsManager.AllActions.Add(new ActionType(className, tempAction));
                            }
                        }
                        else
                        {
                            ACDebug.LogError("The script '" + f.FullName + "' must derive from AC's Action class in order to be available as an Action.");
                        }
                    }
                    catch {}
                }
            }

            actionsManager.AllActions.Sort(delegate(ActionType i1, ActionType i2) { return(i1.GetFullTitle(true).CompareTo(i2.GetFullTitle(true))); });
            actionsManager.SetEnabled();
        }
Пример #30
0
        public static void ModifyAction(ActionListAsset _target, AC.Action _action, string callback)
        {
            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            if (actionsManager == null)
            {
                return;
            }

            int i = -1;

            if (_action != null && _target.actions.IndexOf(_action) > -1)
            {
                i = _target.actions.IndexOf(_action);
            }

            switch (callback)
            {
            case "Enable":
                Undo.RecordObject(_target, "Enable action");
                _target.actions [i].isEnabled = true;
                break;

            case "Disable":
                Undo.RecordObject(_target, "Disable action");
                _target.actions [i].isEnabled = false;
                break;

            case "Cut":
                Undo.RecordObject(_target, "Cut action");
                List <AC.Action> cutList   = new List <AC.Action>();
                AC.Action        cutAction = Object.Instantiate(_action) as AC.Action;
                cutAction.name = cutAction.name.Replace("(Clone)", "");
                cutList.Add(cutAction);
                AdvGame.copiedActions = cutList;
                _target.actions.Remove(_action);
                Undo.DestroyObjectImmediate(_action);
                //UnityEngine.Object.DestroyImmediate (_action, true);
                AssetDatabase.SaveAssets();
                break;

            case "Copy":
                List <AC.Action> copyList   = new List <AC.Action>();
                AC.Action        copyAction = Object.Instantiate(_action) as AC.Action;
                copyAction.ClearIDs();
                copyAction.name = copyAction.name.Replace("(Clone)", "");
                copyList.Add(copyAction);
                AdvGame.copiedActions = copyList;
                break;

            case "Paste after":
                Undo.RecordObject(_target, "Paste actions");
                List <AC.Action> pasteList = AdvGame.copiedActions;
                int j = i + 1;
                foreach (AC.Action action in pasteList)
                {
                    if (action == null)
                    {
                        ACDebug.LogWarning("Error when pasting Action - cannot find original. Did you change scene before pasting? If you need to transfer Actions between scenes, copy them to an ActionList asset first.");
                        continue;
                    }

                    AC.Action pastedAction = Object.Instantiate(action) as AC.Action;
                    pastedAction.name      = pastedAction.name.Replace("(Clone)", "");
                    pastedAction.hideFlags = HideFlags.HideInHierarchy;
                    _target.actions.Insert(j, pastedAction);
                    j++;
                    AssetDatabase.AddObjectToAsset(pastedAction, _target);
                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(pastedAction));
                }
                AssetDatabase.SaveAssets();
                break;

            case "Insert after":
                Undo.RecordObject(_target, "Create action");
                Action newAction = ActionListAssetEditor.AddAction(actionsManager.GetDefaultAction(), i + 1, _target);
                newAction.endAction        = _action.endAction;
                newAction.skipAction       = -1;
                newAction.skipActionActual = _action.skipActionActual;
                break;

            case "Delete":
                Undo.RecordObject(_target, "Delete action");
                _target.actions.Remove(_action);
                Undo.DestroyObjectImmediate(_action);
                //UnityEngine.Object.DestroyImmediate (_action, true);
                AssetDatabase.SaveAssets();
                break;

            case "Move to top":
                Undo.RecordObject(_target, "Move action to top");
                _target.actions.Remove(_action);
                _target.actions.Insert(0, _action);
                break;

            case "Move up":
                Undo.RecordObject(_target, "Move action up");
                _target.actions.Remove(_action);
                _target.actions.Insert(i - 1, _action);
                break;

            case "Move to bottom":
                Undo.RecordObject(_target, "Move action to bottom");
                _target.actions.Remove(_action);
                _target.actions.Insert(_target.actions.Count, _action);
                break;

            case "Move down":
                Undo.RecordObject(_target, "Move action down");
                _target.actions.Remove(_action);
                _target.actions.Insert(i + 1, _action);
                break;
            }
        }