/**
  * <summary>Unregisters a ConstantID, so that it is no longer updated</summary>
  * <param name = "_object">The ConstantID to unregister</param>
  */
 public void Unregister(ConstantID _object)
 {
     if (constantIDs.Contains(_object))
     {
         constantIDs.Remove(_object);
     }
 }
示例#2
0
        private static void SearchSceneForReferences(ConstantID _constantID, string suffix = "")
        {
            SetParametersBase[] setParametersBases = FindObjectsOfType <SetParametersBase>();
            foreach (SetParametersBase setParametersBase in setParametersBases)
            {
                if (setParametersBase.ReferencesObjectOrID(_constantID.gameObject, _constantID.constantID))
                {
                    Debug.Log("'" + _constantID.gameObject.name + "' is referenced by '" + setParametersBase.name + "'" + suffix, setParametersBase);
                }
            }

            ActionList[] localActionLists = FindObjectsOfType <ActionList>();
            foreach (ActionList actionList in localActionLists)
            {
                if (actionList.source == ActionListSource.InScene)
                {
                    foreach (Action action in actionList.actions)
                    {
                        if (action != null)
                        {
                            if (action.ReferencesObjectOrID(_constantID.gameObject, _constantID.constantID))
                            {
                                string actionLabel = (KickStarter.actionsManager != null) ? (" (" + KickStarter.actionsManager.GetActionTypeLabel(action) + ")") : "";
                                Debug.Log("'" + _constantID.gameObject.name + "' is referenced by Action #" + actionList.actions.IndexOf(action) + actionLabel + " in ActionList '" + actionList.gameObject.name + "'" + suffix, actionList);
                            }
                        }
                    }
                }
                else if (actionList.source == ActionListSource.AssetFile)
                {
                    SearchActionListAssetForReferences(_constantID, actionList.assetFile);
                }
            }
        }
示例#3
0
文件: Action.cs 项目: IJkeB/Ekster1
        public Transform AssignFile(List <ActionParameter> parameters, int _parameterID, int _constantID, Transform field)
        {
            Transform file = field;

            ActionParameter parameter = GetParameterWithID(parameters, _parameterID);

            if (parameter != null && parameter.parameterType == ParameterType.GameObject)
            {
                if (!isAssetFile && parameter.gameObject != null)
                {
                    file = parameter.gameObject.transform;
                }
                else if (parameter.intValue != 0)
                {
                    ConstantID idObject = Serializer.returnComponent <ConstantID> (parameter.intValue);
                    if (idObject != null)
                    {
                        file = idObject.gameObject.transform;
                    }
                }
            }
            else if (_constantID != 0)
            {
                ConstantID idObject = Serializer.returnComponent <ConstantID> (_constantID);
                if (idObject != null)
                {
                    file = idObject.gameObject.transform;
                }
            }

            return(file);
        }
示例#4
0
文件: Action.cs 项目: IJkeB/Ekster1
        protected GameObject AssignFile(List <ActionParameter> parameters, int _parameterID, int _constantID, GameObject field)
        {
            GameObject file = field;

            ActionParameter parameter = GetParameterWithID(parameters, _parameterID);

            if (parameter != null && parameter.parameterType == ParameterType.GameObject)
            {
                file = null;
                if (parameter.gameObject != null)
                {
                    file = parameter.gameObject;
                }
                else if (parameter.intValue != 0)
                {
                    ConstantID idObject = Serializer.returnComponent <ConstantID> (parameter.intValue);
                    if (idObject != null)
                    {
                        file = idObject.gameObject;
                    }
                }
            }
            else if (_constantID != 0)
            {
                ConstantID idObject = Serializer.returnComponent <ConstantID> (_constantID);
                if (idObject != null)
                {
                    file = idObject.gameObject;
                }
            }

            return(file);
        }
 /**
  * <summary>Registers a ConstantID, so that it can be updated</summary>
  * <param name = "_object">The ConstantID to register</param>
  */
 public void Register(ConstantID _object)
 {
     if (!constantIDs.Contains(_object))
     {
         constantIDs.Add(_object);
     }
 }
示例#6
0
文件: Action.cs 项目: IJkeB/Ekster1
        public GameObject IDToField(GameObject field, int _constantID, bool moreInfo)
        {
            if (isAssetFile || (!isAssetFile && (field == null || !field.activeInHierarchy)))
            {
                if (_constantID != 0)
                {
                    ConstantID newID = Serializer.returnComponent <ConstantID> (_constantID);
                    if (newID != null && !Application.isPlaying)
                    {
                        field = newID.gameObject;
                    }

                    EditorGUILayout.BeginVertical("Button");
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Recorded ConstantID: " + _constantID.ToString(), EditorStyles.miniLabel);
                    if (field == null)
                    {
                        if (GUILayout.Button("Search scenes", EditorStyles.miniButton))
                        {
                            AdvGame.FindObjectWithConstantID(_constantID);
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    if (field == null && moreInfo)
                    {
                        EditorGUILayout.HelpBox("Further controls cannot display because the referenced object cannot be found.", MessageType.Warning);
                    }
                    EditorGUILayout.EndVertical();
                }
            }
            return(field);
        }
示例#7
0
        /**
         * Called after a scene change.
         */
        public void AfterLoad()
        {
            // Search for duplicates carried over from scene change
            ConstantID ownConstantID = GetComponent <ConstantID>();

            if (ownConstantID != null)
            {
                Sound[] allSceneSounds = FindObjectsOfType(typeof(Sound)) as Sound[];
                foreach (Sound otherSound in allSceneSounds)
                {
                    if (otherSound != this)
                    {
                        ConstantID otherConstantID = otherSound.GetComponent <ConstantID>();
                        if (otherConstantID != null && otherConstantID.constantID == ownConstantID.constantID)
                        {
                            if (otherSound.IsPlaying())
                            {
                                DestroyImmediate(gameObject);
                            }
                            else
                            {
                                DestroyImmediate(otherSound.gameObject);
                            }
                            return;
                        }
                    }
                }
            }
        }
示例#8
0
        private int GetParameterReferences(List <ActionParameter> parameters, int _ID, ParameterType _paramType, int variablesConstantID = 0)
        {
            int thisCount = 0;

            foreach (ActionParameter parameter in parameters)
            {
                if (parameter != null && parameter.parameterType == _paramType && _ID == parameter.intValue)
                {
                    if (_paramType == ParameterType.ComponentVariable && variablesConstantID != 0)
                    {
                        if (parameter.variables)
                        {
                            ConstantID _constantID = parameter.variables.GetComponent <ConstantID>();
                            if (!_constantID || _constantID.constantID != variablesConstantID)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }

                    thisCount++;
                }
            }

            return(thisCount);
        }
示例#9
0
        /**
         * <summary>Updates the record of the Player's current position, based on data made when their scene was not active</summary>
         * <param name = "sceneInstance">The scene instance of the Player to affect</param>
         */
        public void UpdateFromTempPosition(Player sceneInstance)
        {
            if (tempPlayerStart == 0)
            {
                return;
            }

            PlayerStart playerStart = null;

            switch (tempTeleportPlayerStartMethod)
            {
            case TeleportPlayerStartMethod.SceneDefault:
                playerStart = KickStarter.sceneSettings.defaultPlayerStart;
                break;

            case TeleportPlayerStartMethod.BasedOnPrevious:
                playerStart = KickStarter.sceneSettings.GetPlayerStart(playerID);
                break;

            case TeleportPlayerStartMethod.EnteredHere:
                // Search the scene the Player is in, in case the character is in a sub-scene
                Scene sceneToSearch = (sceneInstance.gameObject.IsPersistent())
                                                                                  ? SceneChanger.CurrentScene
                                                                                  : sceneInstance.gameObject.scene;
                playerStart = ConstantID.GetComponent <PlayerStart> (tempPlayerStart, sceneToSearch);
                break;
            }

            UpdatePositionFromPlayerStart(playerStart);
        }
        /**
         * <summary>Serialises appropriate GameObject values into a string.</summary>
         * <returns>The data, serialised as a string</returns>
         */
        public override string SaveData()
        {
            TimelineData timelineData = new TimelineData();

            timelineData.objectID      = constantID;
            timelineData.savePrevented = savePrevented;

                        #if UNITY_2017_1_OR_NEWER
            PlayableDirector director = GetComponent <PlayableDirector>();
            timelineData.isPlaying       = (director.state == PlayState.Playing);
            timelineData.currentTime     = director.time;
            timelineData.trackObjectData = "";
            timelineData.timelineAssetID = "";

            if (director.playableAsset != null)
            {
                TimelineAsset timeline = (TimelineAsset)director.playableAsset;

                if (timeline != null)
                {
                    if (saveTimelineAsset)
                    {
                        timelineData.timelineAssetID = AssetLoader.GetAssetInstanceID(timeline);
                    }

                    if (saveBindings)
                    {
                        int[] bindingIDs = new int[timeline.outputTrackCount];
                        for (int i = 0; i < bindingIDs.Length; i++)
                        {
                            TrackAsset trackAsset  = timeline.GetOutputTrack(i);
                            GameObject trackObject = director.GetGenericBinding(trackAsset) as GameObject;
                            bindingIDs[i] = 0;
                            if (trackObject != null)
                            {
                                ConstantID cIDComponent = trackObject.GetComponent <ConstantID>();
                                if (cIDComponent != null)
                                {
                                    bindingIDs[i] = cIDComponent.constantID;
                                }
                            }
                        }

                        for (int i = 0; i < bindingIDs.Length; i++)
                        {
                            timelineData.trackObjectData += bindingIDs[i].ToString();
                            if (i < (bindingIDs.Length - 1))
                            {
                                timelineData.trackObjectData += ",";
                            }
                        }
                    }
                }
            }
                        #else
            ACDebug.LogWarning("The 'Remember Director' component is only compatible with Unity 5.6 onward.", this);
                        #endif

            return(Serializer.SaveScriptData <TimelineData> (timelineData));
        }
示例#11
0
        /** Creates a new instance of the class from string data */
        public static IKCommand LoadData(string data)
        {
            string[] dataArray = data.Split(":"[0]);
            if (dataArray.Length != 2)
            {
                return(null);
            }

            string targetData = dataArray[0];
            int    targetID   = 0;

            if (int.TryParse(targetData, out targetID))
            {
                if (targetID != 0)
                {
                    ConstantID targetConstantID = ConstantID.GetComponent(targetID);
                    if (targetConstantID != null)
                    {
                        string         curveData       = dataArray[1];
                        AnimationCurve transitionCurve = StringToCurve(curveData);
                        if (transitionCurve != null)
                        {
                            return(new IKCommand(targetConstantID.transform, transitionCurve, true));
                        }
                    }
                    else
                    {
                        ACDebug.LogWarning("Could not find IK target with Constant ID = " + targetID);
                    }
                }
            }
            return(null);
        }
示例#12
0
        public void ShowStartDataGUI(string apiPrefix)
        {
            GUILayout.Label("Starting point data for Player " + ID.ToString() + ": " + ((playerOb) ? playerOb.name : "(EMPTY)"), EditorStyles.boldLabel);

            chooseSceneBy = (ChooseSceneBy)CustomGUILayout.EnumPopup("Choose scene by:", chooseSceneBy);
            switch (chooseSceneBy)
            {
            case ChooseSceneBy.Name:
                startingSceneName = CustomGUILayout.TextField("Scene name:", startingSceneName);
                break;

            case ChooseSceneBy.Number:
                startingSceneIndex = CustomGUILayout.IntField("Scene index:", startingSceneIndex);
                break;
            }

            useSceneDefaultPlayerStart = EditorGUILayout.Toggle("Use default PlayerStart?", useSceneDefaultPlayerStart);
            if (!useSceneDefaultPlayerStart)
            {
                PlayerStart playerStart = ConstantID.GetComponent <PlayerStart> (startingPlayerStartID);
                playerStart           = (PlayerStart)CustomGUILayout.ObjectField <PlayerStart> ("PlayerStart:", playerStart, true, apiPrefix + ".startingPlayerStartID", "The PlayerStart that this character starts from.");
                startingPlayerStartID = FieldToID <PlayerStart> (playerStart, startingPlayerStartID);

                if (startingPlayerStartID != 0)
                {
                    CustomGUILayout.BeginVertical();
                    EditorGUILayout.LabelField("Recorded ConstantID: " + startingPlayerStartID.ToString(), EditorStyles.miniLabel);
                    CustomGUILayout.EndVertical();
                }
            }
        }
示例#13
0
        /**
         * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary>
         * <param name = "stringData">The data, serialised as a string</param>
         */
        public override void LoadData(string stringData)
        {
            NavMesh2DData data = Serializer.LoadScriptData <NavMesh2DData> (stringData);

            if (data == null)
            {
                return;
            }
            SavePrevented = data.savePrevented; if (savePrevented)
            {
                return;
            }

            NavigationMesh navMesh = GetComponent <NavigationMesh>();

            if (navMesh != null)
            {
                navMesh.polygonColliderHoles.Clear();
                KickStarter.navigationManager.navigationEngine.ResetHoles(navMesh);

                if (!string.IsNullOrEmpty(data._linkedIDs))
                {
                    int[] linkedIDs = StringToIntArray(data._linkedIDs);
                    for (int i = 0; i < linkedIDs.Length; i++)
                    {
                        PolygonCollider2D polyHole = ConstantID.GetComponent <PolygonCollider2D> (linkedIDs[i]);
                        if (polyHole != null)
                        {
                            navMesh.AddHole(polyHole);
                        }
                    }
                }
            }
        }
示例#14
0
        /**
         * <summary>Serialises appropriate GameObject values into a string.</summary>
         * <returns>The data, serialised as a string</returns>
         */
        public override string SaveData()
        {
            TimelineData timelineData = new TimelineData();

            timelineData.objectID      = constantID;
            timelineData.savePrevented = savePrevented;

            PlayableDirector director = GetComponent <PlayableDirector>();

            timelineData.isPlaying       = (director.state == PlayState.Playing);
            timelineData.currentTime     = director.time;
            timelineData.trackObjectData = string.Empty;
            timelineData.timelineAssetID = string.Empty;

            if (director.playableAsset != null)
            {
                                #if !ACIgnoreTimeline
                TimelineAsset timeline = (TimelineAsset)director.playableAsset;

                if (timeline != null)
                {
                    if (saveTimelineAsset)
                    {
                        timelineData.timelineAssetID = AssetLoader.GetAssetInstanceID(timeline);
                    }

                    if (saveBindings)
                    {
                        int[] bindingIDs = new int[timeline.outputTrackCount];
                        for (int i = 0; i < bindingIDs.Length; i++)
                        {
                            TrackAsset trackAsset  = timeline.GetOutputTrack(i);
                            GameObject trackObject = director.GetGenericBinding(trackAsset) as GameObject;
                            bindingIDs[i] = 0;
                            if (trackObject != null)
                            {
                                ConstantID cIDComponent = trackObject.GetComponent <ConstantID>();
                                if (cIDComponent != null)
                                {
                                    bindingIDs[i] = cIDComponent.constantID;
                                }
                            }
                        }

                        for (int i = 0; i < bindingIDs.Length; i++)
                        {
                            timelineData.trackObjectData += bindingIDs[i].ToString();
                            if (i < (bindingIDs.Length - 1))
                            {
                                timelineData.trackObjectData += ",";
                            }
                        }
                    }
                }
                                #endif
            }

            return(Serializer.SaveScriptData <TimelineData> (timelineData));
        }
        /**
         * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary>
         * <param name = "stringData">The data, serialised as a string</param>
         */
        public void LoadTransformData(TransformData data)
        {
            if (data == null)
            {
                return;
            }
            savePrevented = data.savePrevented; if (savePrevented)
            {
                return;
            }

            if (data.parentIsPlayer)
            {
                if (KickStarter.player)
                {
                    if (data.heldHand == Hand.Left)
                    {
                        transform.parent = KickStarter.player.leftHandBone;
                    }
                    else
                    {
                        transform.parent = KickStarter.player.rightHandBone;
                    }
                }
            }
            else if (data.parentID != 0)
            {
                ConstantID parentObject = Serializer.returnComponent <ConstantID> (data.parentID);

                if (parentObject != null)
                {
                    if (data.parentIsNPC && parentObject.GetComponent <NPC>())
                    {
                        if (data.heldHand == Hand.Left)
                        {
                            transform.parent = parentObject.GetComponent <NPC>().leftHandBone;
                        }
                        else
                        {
                            transform.parent = parentObject.GetComponent <NPC>().rightHandBone;
                        }
                    }
                    else
                    {
                        transform.parent = parentObject.gameObject.transform;
                    }
                }
            }
            else if (data.parentID == 0 && saveParent)
            {
                transform.parent = null;
            }

            transform.position    = new Vector3(data.LocX, data.LocY, data.LocZ);
            transform.eulerAngles = new Vector3(data.RotX, data.RotY, data.RotZ);
            transform.localScale  = new Vector3(data.ScaleX, data.ScaleY, data.ScaleZ);
        }
示例#16
0
        public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
        {
            foreach (TimelineClip timelineClip in GetClips())
            {
                SpeechPlayableClip clip = (SpeechPlayableClip)timelineClip.asset;
                timelineClip.displayName = clip.GetDisplayName();

                Char speaker = null;
                if (Application.isPlaying)
                {
                    if (isPlayerLine)
                    {
                        speaker = AssignPlayer(playerID);
                    }
                    else if (speakerConstantID != 0)
                    {
                        speaker = ConstantID.GetComponent <Char> (speakerConstantID);
                    }
                }
                else
                {
                    if (isPlayerLine)
                    {
                        if (KickStarter.settingsManager != null)
                        {
                            if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow && playerID >= 0)
                            {
                                PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                                if (playerPrefab != null)
                                {
                                    speaker = playerPrefab.playerOb;
                                }
                            }
                            else
                            {
                                speaker = KickStarter.settingsManager.GetDefaultPlayer(false);
                            }
                        }
                    }
                    else
                    {
                        speaker = SpeakerPrefab;
                    }
                }

                clip.speechTrackPlaybackMode = playbackMode;
                clip.speaker         = speaker;
                clip.trackInstanceID = GetInstanceID();
            }

            ScriptPlayable <SpeechPlayableMixer> mixer = ScriptPlayable <SpeechPlayableMixer> .Create(graph);

            mixer.SetInputCount(inputCount);
            mixer.GetBehaviour().trackInstanceID = GetInstanceID();
            mixer.GetBehaviour().playbackMode    = playbackMode;
            return(mixer);
        }
示例#17
0
        private void UnloadPlayerStart(int playerStartInt, SceneSettings sceneSettings)
        {
            PlayerStart playerStart = ConstantID.GetComponent <PlayerStart> (playerStartInt, sceneSettings.gameObject.scene);

            if (playerStart)
            {
                sceneSettings.defaultPlayerStart = playerStart;
            }
        }
示例#18
0
        private void UnloadCutsceneOnStart(int cutsceneInt, SceneSettings sceneSettings)
        {
            Cutscene cutscene = ConstantID.GetComponent <Cutscene> (cutsceneInt, sceneSettings.gameObject.scene);

            if (cutscene)
            {
                sceneSettings.cutsceneOnStart = cutscene;
            }
        }
示例#19
0
        private void UnloadSortingMap(int sortingMapInt, SceneSettings sceneSettings)
        {
            SortingMap sortingMap = ConstantID.GetComponent <SortingMap> (sortingMapInt, sceneSettings.gameObject.scene);

            if (sortingMap)
            {
                sceneSettings.sortingMap = sortingMap;
                KickStarter.sceneSettings.UpdateAllSortingMaps();
            }
        }
示例#20
0
文件: Action.cs 项目: IJkeB/Ekster1
 protected GameObject AssignFile(int _constantID, GameObject field)
 {
     if (_constantID != 0)
     {
         ConstantID newField = Serializer.returnComponent <ConstantID> (_constantID);
         if (newField != null)
         {
             return(newField.gameObject);
         }
     }
     return(field);
 }
示例#21
0
文件: Action.cs 项目: IJkeB/Ekster1
 public Transform AssignFile(int _constantID, Transform field)
 {
     if (_constantID != 0)
     {
         ConstantID newField = Serializer.returnComponent <ConstantID> (_constantID);
         if (newField != null)
         {
             return(newField.transform);
         }
     }
     return(field);
 }
示例#22
0
        /**
         * <summary>Updates its own variables from a VisibilityData class.</summary>
         * <param name = "data">The VisibilityData class to load from</param>
         */
        public void LoadData(VisibilityData data)
        {
            useDefaultTintMap = data.useDefaultTintMap;
            SetIntensity(data.tintIntensity, 0f);

            if (!useDefaultTintMap && data.tintMapID != 0)
            {
                tintMap = ConstantID.GetComponent <TintMap> (data.tintMapID);
            }

            ResetTintMap();
        }
示例#23
0
        /**
         * <summary>Updates the record of the Player's current position</summary>
         * <param name = "newSceneIndex">The scene in which to place the Player in</param>
         * <param name = "teleportPlayerStartMethod">How to select which PlayerStart to appear at (SceneDefault, BasedOnPrevious, EnteredHere)</param>
         * <param name = "playerStartID">The Constant ID value of the PlayerStart for the Player to appear at</param>
         */
        public void UpdatePosition(int newSceneIndex, TeleportPlayerStartMethod teleportPlayerStartMethod, int playerStartID)
        {
            UpdateCurrentAndShiftPrevious(newSceneIndex);

            tempPlayerStart = 0;
            if (newSceneIndex == SceneChanger.CurrentSceneIndex)
            {
                // Updating position to the current scene
                PlayerStart playerStart = null;

                switch (teleportPlayerStartMethod)
                {
                case TeleportPlayerStartMethod.BasedOnPrevious:
                    playerStart = KickStarter.sceneSettings.GetPlayerStart(playerID);
                    break;

                case TeleportPlayerStartMethod.EnteredHere:
                    if (playerStartID != 0)
                    {
                        playerStart = ConstantID.GetComponent <PlayerStart> (playerStartID);
                    }
                    break;

                case TeleportPlayerStartMethod.SceneDefault:
                    playerStart = KickStarter.sceneSettings.defaultPlayerStart;
                    break;

                default:
                    break;
                }

                if (playerStart)
                {
                    UpdatePositionFromPlayerStart(playerStart);
                }
                else if (teleportPlayerStartMethod == TeleportPlayerStartMethod.EnteredHere && playerStartID != 0)
                {
                    ACDebug.LogWarning("Cannot find PlayerStart with Constant ID = " + playerStartID + " for Player ID = " + playerID + " in the current scene.");
                }
                else
                {
                    ACDebug.LogWarning("Cannot find suitable PlayerStart for Player ID = " + playerID + " in the current scene");
                }
            }
            else
            {
                // Position is being set in another scene, so keep a record of it
                tempTeleportPlayerStartMethod = teleportPlayerStartMethod;
                tempPlayerStart = (teleportPlayerStartMethod == TeleportPlayerStartMethod.EnteredHere) ? playerStartID : -1;
            }
        }
示例#24
0
        protected void SharedGUI()
        {
            ConstantID _target = (ConstantID)target;

            EditorGUILayout.BeginVertical("Button");

            EditorGUILayout.LabelField("Constant ID number", EditorStyles.boldLabel);

            _target.autoManual = (AutoManual)CustomGUILayout.EnumPopup("Set:", _target.autoManual, "", "Is the Constant ID set automatically or manually?");

            _target.retainInPrefab = CustomGUILayout.Toggle("Retain in prefab?", _target.retainInPrefab, "", "If True, prefabs will share the same Constant ID as their scene-based counterparts");

            bool ignoreDirty = false;

            if (UnityVersionHandler.IsPrefabFile(_target.gameObject))
            {
                // Prefab
                if (!_target.retainInPrefab && _target.constantID != 0)
                {
                    _target.constantID = 0;
                    // Don't flag as dirty, otherwise get problems with scene instances
                    ignoreDirty = true;
                }
                else if (_target.retainInPrefab && _target.constantID == 0)
                {
                    _target.SetNewID_Prefab();
                }
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("ID:", "The recorded Constant ID number"), GUILayout.Width(50f));
            if (_target.autoManual == AutoManual.Automatic)
            {
                EditorGUILayout.LabelField(_target.constantID.ToString());
            }
            else
            {
                _target.constantID = EditorGUILayout.DelayedIntField(_target.constantID);
            }
            if (GUILayout.Button("Copy number"))
            {
                EditorGUIUtility.systemCopyBuffer = _target.constantID.ToString();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            if (!ignoreDirty)
            {
                UnityVersionHandler.CustomSetDirty(_target);
            }
        }
示例#25
0
        /**
         * <summary>Registers a ConstantID component in the Hierarchy</summary>
         * <param name = "constantID">The ConstantID to register</param>
         */
        public void Register(ConstantID constantID)
        {
            if (constantID is Remember)
            {
                Canvas canvas = constantID.transform.root.GetComponent <Canvas>();
                if (canvas && canvas.gameObject.IsPersistent())
                {
                    MenuConstantIDs.Add(constantID);
                    return;
                }
            }

            ConstantIDs.Add(constantID);
        }
示例#26
0
        /**
         * <summary>Unregisters a ConstantID component</summary>
         * <param name = "constantID">The ConstantID to unregister</param>
         */
        public void Unregister(ConstantID constantID)
        {
            if (constantID is Remember)
            {
                Canvas canvas = constantID.transform.root.GetComponent <Canvas> ();
                if (canvas && canvas.gameObject.IsPersistent())
                {
                    // Always keep UI ConstantIDs registered
                    return;
                }
            }

            ConstantIDs.Remove(constantID);
        }
 public void LoadData(string dataString)
 {
     if (parameterType == ParameterType.Float)
     {
         floatValue = 0f;
         float.TryParse(dataString, out floatValue);
     }
     else if (parameterType == ParameterType.String)
     {
         stringValue = AdvGame.PrepareStringForLoading(dataString);
     }
     else if (parameterType == ParameterType.GameObject)
     {
         gameObject = null;
         int constantID = 0;
         if (int.TryParse(dataString, out constantID))
         {
             ConstantID _constantID = Serializer.returnComponent <ConstantID> (constantID);
             if (_constantID != null)
             {
                 gameObject = _constantID.gameObject;
             }
         }
     }
     else if (parameterType == ParameterType.UnityObject)
     {
         if (dataString == "")
         {
             objectValue = null;
         }
         else
         {
             Object[] objects = (Object[])Resources.LoadAll("");
             foreach (Object _object in objects)
             {
                 if (_object.name == dataString)
                 {
                     objectValue = _object;
                     return;
                 }
             }
         }
     }
     else
     {
         intValue = 0;
         int.TryParse(dataString, out intValue);
     }
 }
示例#28
0
        public static void FindLocalReferences(MenuCommand command)
        {
            ConstantID _constantID = (ConstantID)command.context;

            if (_constantID != null)
            {
                if (_constantID.constantID == 0)
                {
                    ACDebug.LogWarning("Cannot find references for " + _constantID.name + " because it's ConstantID value is zero!", _constantID);
                    return;
                }

                SearchSceneForReferences(_constantID);
            }
        }
示例#29
0
        override public void AssignValues(List <ActionParameter> parameters)
        {
            if (parameters != null)
            {
                ownParameters = parameters;
            }

            runtimeSpeaker = AssignFile <Char> (parameters, parameterID, constantID, speaker);

            // Special case: Use associated NPC
            if (runtimeSpeaker != null &&
                runtimeSpeaker is Player &&
                KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow &&
                KickStarter.player != null)
            {
                // Make sure not the active Player
                ConstantID speakerID = speaker.GetComponent <ConstantID>();
                ConstantID playerID  = KickStarter.player.GetComponent <ConstantID>();
                if ((speakerID == null && playerID != null) ||
                    (speakerID != null && playerID == null) ||
                    (speakerID != null && playerID != null && speakerID.constantID != playerID.constantID))
                {
                    Player speakerPlayer = runtimeSpeaker as Player;
                    foreach (PlayerPrefab playerPrefab in KickStarter.settingsManager.players)
                    {
                        if (playerPrefab != null && playerPrefab.playerOb == speakerPlayer)
                        {
                            if (speakerPlayer.associatedNPCPrefab != null)
                            {
                                ConstantID npcConstantID = speakerPlayer.associatedNPCPrefab.GetComponent <ConstantID>();
                                if (npcConstantID != null)
                                {
                                    runtimeSpeaker = AssignFile <Char> (parameters, parameterID, npcConstantID.constantID, runtimeSpeaker);
                                }
                            }
                            break;
                        }
                    }
                }
            }

            messageText = AssignString(parameters, messageParameterID, messageText);

            if (isPlayer)
            {
                runtimeSpeaker = KickStarter.player;
            }
        }
示例#30
0
        private void UnloadTintMap(int tintMapInt, SceneSettings sceneSettings)
        {
            TintMap tintMap = ConstantID.GetComponent <TintMap> (tintMapInt, sceneSettings.gameObject.scene);

            if (tintMap)
            {
                sceneSettings.tintMap = tintMap;

                // Reset all FollowTintMap components
                FollowTintMap[] followTintMaps = FindObjectsOfType(typeof(FollowTintMap)) as FollowTintMap[];
                foreach (FollowTintMap followTintMap in followTintMaps)
                {
                    followTintMap.ResetTintMap();
                }
            }
        }