示例#1
0
        public static SaveCollector AddLogicCollector()
        {
            GameObject    go        = new GameObject("LogicCollector");
            SaveCollector collector = go.AddComponent <SaveCollector>();

            Selection.activeGameObject = go;
            return(collector);
        }
示例#2
0
        public static void CollectObjects()
        {
            SaveCollector collector = FindObjectOfType <SaveCollector>();

            if (collector == null)
            {
                collector = AddLogicCollector();
            }

            IEnumerable <ISaveable> saveables = FindObjectsOfType <MonoBehaviour>().OfType <ISaveable>();

            foreach (ISaveable saveable in saveables)
            {
                if (saveable.GO.transform.parent != null)
                {
                    continue;
                }

                Undo.RecordObject(saveable.GO.transform, "Set new parent");
                saveable.GO.transform.SetParent(collector.transform);
            }
        }