Пример #1
0
        public void LoadPrefabs()
        {
            List <RecreateModule> modules = new List <RecreateModule>();

            //var paths = UnityEditor.AssetDatabase.FindAssets("t:" + typeof(Substance).ToString());
            //foreach (var path in paths)
            //{
            //    substances.Add(UnityEditor.AssetDatabase.LoadAssetAtPath<Substance>(path));
            //}

            string[] guids = AssetDatabase.FindAssets("t:GameObject");
            foreach (var guid in guids)
            {
                string path = AssetDatabase.GUIDToAssetPath(guid);

                RecreateModule m = AssetDatabase.LoadAssetAtPath <RecreateModule>(path);
                if (m != null)
                {
                    if (string.IsNullOrEmpty(m.prefabGuid))
                    {
                        m.prefabGuid = Guid.NewGuid().ToString();
                    }
                    modules.Add(m);
                    //Debug.Log("Path: " + path + " GUID: " + guid);
                }
            }
            serializedModules = modules.ToArray();

            //AssetDatabase.SaveAssets();
            EditorUtility.SetDirty(this);
            AssetDatabase.SaveAssets();
        }
Пример #2
0
        public RecreateModule Recreate(RecreateModule ghost, Vector3 originPosition, Quaternion originRotation, Vector3 originScale, Transform originParent)
        {
            var vessel = serializedModules.FirstOrDefault(m => Equals(m.prefabGuid, ghost.prefabGuid)); // Maybe make it more specific

            if (vessel != null)
            {
                RecreateModule o = Instantiate(vessel, originPosition, originRotation, originParent);
                o.SetLocalScale(originScale);
                return(o);
            }
            else
            {
                Debug.Log("Recreate prefab was not found for: " + ghost.name + " guid: " + ghost.prefabGuid);
            }
            return(null);
        }
Пример #3
0
        public void OnReset()
        {
            bool isInOrder = maxCheckpointOrder < 0 || maxCheckpointOrder >= CheckpointManager.CurrentOrder;

            //if(maxCheckpointOrder >= 0)
            //    Debug.Log("CurrentCheckpointOrder: " + CheckpointManager.CurrentOrder + " MaxO: "+maxCheckpointOrder+" IsO: "+isInOrder);

            if (!wasReset && isInOrder)
            {
                if (!wasDestroied)
                {
                    Destroy(gameObject);
                }
                Deregister();

                RecreateModule newModule = RecreateManager.Instance.Recreate(this, position, rotation, scale, parent);
                if (newModule != null)
                {
                    newModule.maxCheckpointOrder = maxCheckpointOrder;
                }

                wasReset = true;
            }
        }