Example #1
0
    public static void PushLoadedAssetInfo(ResNode res, PrefabDependenciesResNode resNode = null)
    {
#if OpenAssetDebug
        if (!LoadedAssetInfoParentRoot)
        {
            LoadedAssetInfoParentRoot      = new GameObject();
            LoadedAssetInfoParentRoot.name = "LoadedAssetInfoParentRoot";
            GameObject.DontDestroyOnLoad(LoadedAssetInfoParentRoot);
        }

        LoadedAssetInfo info = null;
        if (m_Table.TryGetValue(res.instanceID, out info))
        {
            if (!info)
            {
                GameObject go = new GameObject();
                go.name = res.AssetName;
                go.transform.SetParent(LoadedAssetInfoParentRoot.transform);
                info = go.AddComponent <LoadedAssetInfo>();
                m_Table[res.instanceID] = info;
            }
        }
        else
        {
            GameObject go = new GameObject();
            go.name = res.AssetName;
            go.transform.SetParent(LoadedAssetInfoParentRoot.transform);
            info = go.AddComponent <LoadedAssetInfo>();
            m_Table.Add(res.instanceID, info);
        }

        info.Clear();
        info.InsertResIno(res, resNode);
#endif
    }
Example #2
0
        private IEnumerable <LoadedAssetInfo> LoadAllAssetsAtPathProperly(string path)
        {
            if (!path.FastEndsWith(".prefab"))
            {
                // Not a prefab, we can just do it the normal way
                var assets = AssetDatabase.LoadAllAssetsAtPath(path);
                var result = new LoadedAssetInfo[assets.Length];

                for (int i = 0; i < assets.Length; i++)
                {
                    result[i] = new LoadedAssetInfo(assets[i]);
                }

                return(result);
            }

            // It's a prefab; we need to get fancy with it, since AssetDatabase.LoadAllAssetsAtPath often loads broken null values for prefabs instead of loading them properly
            var mainAsset = AssetDatabase.LoadMainAssetAtPath(path) as GameObject;

            if (mainAsset == null)
            {
                return(new LoadedAssetInfo[0]);                   // Nevermind I guess
            }
            return(this.RecurseThroughPrefab(mainAsset));
        }
Example #3
0
        public AssetCache(string assetName, LoadedAssetInfo assetInfo)
        {
            AssetName = assetName;
            Reference = 0;

            _asset = assetInfo.asset as GameObject;

            if (assetInfo.instance != null)
            {
                _assetList.Add(assetInfo.instance as GameObject);
                Reference++;
            }
        }