Example #1
0
        // For sub-buildings, name may be package.assetname.
        static T Get <T>(Package package, string fullName, string name, bool tryName) where T : PrefabInfo
        {
            T info = PrefabCollection <T> .FindLoaded(fullName);

            if (info == null && tryName)
            {
                info = PrefabCollection <T> .FindLoaded(name);
            }

            if (info == null)
            {
                Package.Asset data = package.Find(name);

                if (data == null && tryName)
                {
                    data = UsedAssets.FindAsset(name);   // yes, name
                }
                if (data != null)
                {
                    fullName = data.fullName;
                }
                else if (name.Contains("."))
                {
                    fullName = name;
                }

                if (AssetLoader.instance.LoadAsset(fullName, data))
                {
                    info = PrefabCollection <T> .FindLoaded(fullName);
                }
            }

            return(info);
        }
Example #2
0
        // Works with (fullName = asset name), too.
        static T Get <T>(string fullName) where T : PrefabInfo
        {
            if (string.IsNullOrEmpty(fullName))
            {
                return(null);
            }

            T info = PrefabCollection <T> .FindLoaded(fullName);

            if (info == null && AssetLoader.instance.LoadAsset(fullName, UsedAssets.FindAsset(fullName)))
            {
                info = PrefabCollection <T> .FindLoaded(fullName);
            }

            return(info);
        }