Exemplo n.º 1
0
        void CheckID(Object obj)
        {
            SceneSerializer data = obj as SceneSerializer;

            //check if we need to generate keys
            if (mRefs == null || mRefScene != EditorApplication.currentScene)
            {
                RegenerateIDs();
            }
            else if (data.id == SceneSerializer.invalidID || mRefs[data.id] != data)
            {
                int nid = 1;
                for (; ; nid++)
                {
                    if (mRefs.ContainsKey(nid))
                    {
                        if (mRefs[nid] == null)  //was deleted for some reason
                        {
                            mRefs.Remove(nid);
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                data.__SetID(nid);
                mRefs.Add(nid, data);
                EditorUtility.SetDirty(data);
            }
        }
            public void Spawn()
            {
                var spawned = PoolController.SpawnFromGroup(grp, type, type + id, null, pos, rot, null);

                SceneSerializer ss = spawned.GetComponent <SceneSerializer>();

                ss.__SetID(id);
            }
            public void Spawn()
            {
                Transform t = PoolController.Spawn(grp, type, type + id, null, pos, rot);

                SceneSerializer ss = t.GetComponent <SceneSerializer>();

                ss.__SetID(id);
            }
Exemplo n.º 4
0
        public static SceneSerializer GetObject(int id)
        {
            SceneSerializer ret = null;

            if (mRefs != null)
            {
                mRefs.TryGetValue(id, out ret);
            }

            return(ret);
        }
Exemplo n.º 5
0
        void Awake()
        {
            SceneManager.instance.sceneChangeCallback += OnSceneLoad;

            if (persistent && UserData.main)
            {
                UserData.main.actCallback += OnUserDataAction;
            }

            mSerializer = GetComponent <SceneSerializer>();
        }
        void Awake()
        {
            if (!serializer)
            {
                serializer = GetComponent <SceneSerializer>();
            }

            if (serializer.isLoaded)
            {
                OnUserDataLoaded();
            }

            serializer.loadedCallback += OnUserDataLoaded;
            serializer.saveCallback   += OnUserDataSave;
        }
Exemplo n.º 7
0
        protected virtual void Awake()
        {
            mPoolData = GetComponent <PoolDataController>();

            mSerializer = GetComponent <SceneSerializer>();

            if (activator == null)
            {
                activator = GetComponentInChildren <EntityActivator>();
            }

            if (activator != null)
            {
                activator.awakeCallback += ActivatorWakeUp;
                activator.sleepCallback += ActivatorSleep;
            }
        }
Exemplo n.º 8
0
        public override void OnInspectorGUI()
        {
            SceneSerializer data = target as SceneSerializer;

            //this shouldn't be in a prefab...

            if (Application.isPlaying)
            {
                EditorGUILayout.LabelField("id", data.id.ToString());
            }
            else if (targets != null && targets.Length > 1)
            {
                foreach (Object obj in targets)
                {
                    PrefabType prefabType = PrefabUtility.GetPrefabType(obj);
                    if (prefabType == PrefabType.Prefab || prefabType == PrefabType.ModelPrefab)
                    {
                        continue;
                    }

                    CheckID(obj);
                }

                EditorGUILayout.LabelField("id", "--");
            }
            else
            {
                PrefabType prefabType = PrefabUtility.GetPrefabType(target);
                if (prefabType == PrefabType.Prefab || prefabType == PrefabType.ModelPrefab)
                {
                    EditorGUILayout.LabelField("id", "??");
                    return;
                }

                CheckID(target);

                EditorGUILayout.LabelField("id", data.id.ToString());
            }

            //sanity check
            if (GUILayout.Button("Verify Integrity"))
            {
                RegenerateIDs();
                Repaint();
            }
        }
Exemplo n.º 9
0
        void CheckID(Object obj)
        {
            SceneSerializer data = obj as SceneSerializer;

            //check if we need to generate keys
            if (mRefs == null || mRefScene != EditorSceneManager.GetActiveScene().name)
            {
                RegenerateIDs();
            }
            else if (data.id == SceneSerializer.invalidID || mRefs[data.id] != data)
            {
                int nid = 1;
                for (; ; nid++)
                {
                    if (mRefs.ContainsKey(nid))
                    {
                        if (mRefs[nid] == null)  //was deleted for some reason
                        {
                            mRefs.Remove(nid);
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                data.__SetID(nid);
                mRefs.Add(nid, data);

                //don't want to undo this
                //TODO: can't really determine which scene this object belongs to, just mark them all...
                EditorSceneManager.MarkAllScenesDirty();
            }
        }