public static void LoadRefCounter <T>(IResourceReference reference, ResourceBase resource, System.Action <T> callbackOnLoad, System.Action callbackOnFailed, bool async) /*where T : Object*/ { if (WindowSystemResources.instance != null) { WindowSystemResources.instance.LoadRefCounter_INTERNAL <T>(reference, resource, callbackOnLoad, callbackOnFailed, async, customResourcePath: null); } }
public virtual void Validate(Object item) { if (item == null) { return; } this.assetPath = UnityEditor.AssetDatabase.GetAssetPath(item); #region Resources { var resourcePath = (this.assetPath.Contains("/Resources/") == true ? this.assetPath.Split(new string[] { "/Resources/" }, System.StringSplitOptions.None)[1] : string.Empty); var ext = System.IO.Path.GetExtension(resourcePath); this.resourcesPath = resourcePath.Substring(0, resourcePath.Length - ext.Length); this.loadableResource = (string.IsNullOrEmpty(this.resourcesPath) == false); } #endregion #region StreamingAssets { var streamingAssetsPath = (this.assetPath.Contains("/StreamingAssets/") == true ? this.assetPath.Split(new string[] { "/StreamingAssets/" }, System.StringSplitOptions.None)[1] : string.Empty); var platformSplit = streamingAssetsPath.Split(new char[] { '/' }, System.StringSplitOptions.RemoveEmptyEntries); if (platformSplit.Length > 0) { var localPath = string.Join("/", platformSplit, 1, platformSplit.Length - 1); var localDir = System.IO.Path.GetDirectoryName(localPath); var filenameWithoutExt = System.IO.Path.GetFileNameWithoutExtension(streamingAssetsPath); this.streamingAssetsPathIOS = this.GetPlatformDirectory(Platform.iOS, localDir, filenameWithoutExt); this.streamingAssetsPathAndroid = this.GetPlatformDirectory(Platform.Android, localDir, filenameWithoutExt); this.streamingAssetsPathStandalone = this.GetPlatformDirectory(Platform.Standalone, localDir, filenameWithoutExt); this.streamingAssetsPathPS4 = this.GetPlatformDirectory(Platform.PS4, localDir, filenameWithoutExt); this.streamingAssetsPathXBOXONE = this.GetPlatformDirectory(Platform.XBOXONE, localDir, filenameWithoutExt); this.streamingAssetsPathCommon = this.GetPlatformDirectory(Platform.Common, localDir, filenameWithoutExt); this.streamingAssetsPathIOSMovieAudio = this.GetMovieAudio(this.streamingAssetsPathIOS); this.streamingAssetsPathAndroidMovieAudio = this.GetMovieAudio(this.streamingAssetsPathAndroid); this.streamingAssetsPathStandaloneMovieAudio = this.GetMovieAudio(this.streamingAssetsPathStandalone); this.streamingAssetsPathPS4MovieAudio = this.GetMovieAudio(this.streamingAssetsPathPS4); this.streamingAssetsPathXBOXONEMovieAudio = this.GetMovieAudio(this.streamingAssetsPathXBOXONE); this.streamingAssetsPathCommonMovieAudio = this.GetMovieAudio(this.streamingAssetsPathCommon); /* * if (string.IsNullOrEmpty(this.streamingAssetsPathIOSMovieAudio) == true) this.streamingAssetsPathIOSMovieAudio = this.streamingAssetsPathCommonMovieAudio; * if (string.IsNullOrEmpty(this.streamingAssetsPathAndroidMovieAudio) == true) this.streamingAssetsPathAndroidMovieAudio = this.streamingAssetsPathCommonMovieAudio; * if (string.IsNullOrEmpty(this.streamingAssetsPathStandaloneMovieAudio) == true) this.streamingAssetsPathStandaloneMovieAudio = this.streamingAssetsPathCommonMovieAudio; * if (string.IsNullOrEmpty(this.streamingAssetsPathPS4MovieAudio) == true) this.streamingAssetsPathPS4MovieAudio = this.streamingAssetsPathCommonMovieAudio; * if (string.IsNullOrEmpty(this.streamingAssetsPathXBOXONEMovieAudio) == true) this.streamingAssetsPathXBOXONEMovieAudio = this.streamingAssetsPathCommonMovieAudio; */ } this.loadableStream = (string.IsNullOrEmpty(streamingAssetsPath) == false); } #endregion string uniquePath = (this.multiObjects == true) ? (string.Format("{0}#{1}", this.assetPath, this.objectIndex)) : this.assetPath; this.id = ResourceBase.GetJavaHash(uniquePath); }
public static void Unload(IImageComponent resourceController, ResourceBase resource) { if (MovieSystem.instance != null) { MovieSystem.instance.movieModule.Unload(resourceController, resource); } }
public static bool Remove(Item item, IResourceReference component, ResourceBase resource) { if (item == null) { //Debug.LogWarning("[WindowSystemResources] Trying to remove failed with null in `item`."); return(false); } if (item.references == null) { //Debug.LogWarning("[WindowSystemResources] Trying to remove failed with null in `references`."); return(false); } if (item.references.Remove(component) == true) { #if UNITY_EDITOR item.referencesCount = item.references.Count; #endif return(WindowSystemResources.RemoveIfRefsZero_INTERNAL(item, resource)); } return(false); }
private void LoadCustom_INTERNAL <T>(ResourceBase resource, System.Action <T> callback) where T : MonoBehaviour { if (resource is MonoResource) { this.StartCoroutine(resource.Load <T>(null, null, null, callback)); } }
private bool IsLoaded <T>(IResourceReference reference, ResourceBase resource, out Item item, System.Action <T> callbackLoaded, System.Action callbackFailed) /*where T : Object*/ { var typeOf = typeof(T); var itemInner = this.loaded.FirstOrDefault(x => x.id == resource.GetId() && x.type == typeOf /*(x.@object == null || x.@object is T)*/); if (itemInner != null) { item = itemInner; if (itemInner.references.Contains(reference) == false) { itemInner.references.Add(reference); #if UNITY_EDITOR itemInner.referencesCount = itemInner.references.Count; #endif } else { //Debug.LogError("IsLoaded returns `true` but reference already in list.", reference); } if (itemInner.loaded == false) { this.OnItemCallback_INTERNAL <T>(itemInner, resource, callbackLoaded, callbackFailed); } else { if (itemInner.loadingResult == true) { callbackLoaded.Invoke((T)itemInner.loadedObject); } else { callbackFailed.Invoke(); } } return(true); } item = new Item() { id = resource.GetId(), type = typeOf, loadedObject = null, loaded = false, references = new List <IResourceReference>() { reference } }; #if UNITY_EDITOR item.referencesCount = 1; #endif this.loaded.Add(item); this.OnItemCallback_INTERNAL(item, resource, callbackLoaded, callbackFailed); return(false); }
private IEnumerator LoadResource_INTERNAL <T>(ResourceBase resource, IImageComponent component, Graphic graphic, string customResourcePath, System.Action <T> callback) where T : Object { if (this.taskInterations == null) { this.taskInterations = new Dictionary <Graphic, int>(); } var iteration = 0; if (graphic != null) { if (this.taskInterations.TryGetValue(graphic, out iteration) == false) { this.taskInterations.Add(graphic, ++iteration); } } var task = new TaskItem(); task.id = resource.GetId(); task.resource = resource; task.component = component; task.graphic = graphic; task.customResourcePath = customResourcePath; task.onSuccess = (obj) => { if (graphic != null) { var iterationFailed = !(graphic == null || iteration == this.taskInterations[graphic]); if (iterationFailed == false) { callback.Invoke(obj as T); } else { task.onFailed.Invoke(); } } else { callback.Invoke(obj as T); } }; task.onFailed = () => { callback.Invoke(null); }; this.tasks.Add(task); //Debug.Log("Resource Task: " + task.resource.assetPath); yield return(this.StartCoroutine(this.StartTask <T>(task))); task.Dispose(); this.tasks.Remove(task); }
public static object GetResourceObjectById(ResourceBase resource) { var item = WindowSystemResources.GetItem(resource); if (item == null) { return(null); } return(item.loadedObject); }
public static bool IsResourceObjectLoaded(ResourceBase resource) { var item = WindowSystemResources.GetItem(resource); if (item == null) { return(false); } return(item.loaded); }
public static ResourceAuto CreateResourceRequest(string path, bool readable = false) { var item = new ResourceAuto(); item.async = true; item.id = ResourceBase.GetJavaHash(path); item.controlType = ControlType.Show | ControlType.Hide; item.loadableResource = true; item.readableTexture = readable; item.resourcesPath = path; return(item); }
private void LoadRefCounter_INTERNAL <T>(IResourceReference reference, ResourceBase resource, System.Action <T> callbackOnLoad, System.Action callbackOnFailed, bool async, string customResourcePath) /*where T : Object*/ { if (resource.IsLoadable() == true) { //Debug.Log("Check: " + resource.assetPath + ", typeof: " + typeof(T).ToString()); Item item; if (this.IsLoaded <T>(reference, resource, out item, callbackOnLoad, callbackOnFailed) == false) { //Debug.Log("Loading: " + resource.assetPath); Coroutines.Run(resource.Load <T>(reference, customResourcePath, (data) => { //Debug.Log("Loaded: " + resource.assetPath + " >> " + data); if (data == null) { //Debug.LogWarning(string.Format("Failed to load resource in {0}", resource.assetPath)); item.loadingResult = false; if (item.onObjectFailed != null) { item.onObjectFailed.Invoke(item); } item.onObjectLoaded = null; item.onObjectFailed = null; //if (callbackOnFailed != null) callbackOnFailed.Invoke(); //WindowSystemLogger.Error(image, string.Format("Error in ResourcesManager: Required resource can't loaded. Resource: {0}", image.GetResource().GetId())); return; } item.loadingResult = true; item.loadedObject = data; item.loaded = true; if (item.onObjectLoaded != null) { item.onObjectLoaded.Invoke(item); } item.onObjectLoaded = null; item.onObjectFailed = null; //callbackOnLoad(data); }, async)); } } else { if (callbackOnFailed != null) { callbackOnFailed.Invoke(); } } }
public static ResourceAuto CreateWebRequest(string path, int cacheVersion = 0, bool readable = false) { var item = new ResourceAuto(); item.async = true; item.id = ResourceBase.GetJavaHash(path); item.controlType = ControlType.Show | ControlType.Hide; item.loadableWeb = true; item.cacheVersion = cacheVersion; item.readableTexture = readable; item.webPath = path; return(item); }
private void Unload_INTERNAL(ILoadableResource resourceController, ResourceBase resource, bool resetController = true) { if (resource.loaded == false) { return; } //Debug.LogWarning("Unload: " + resource.GetId(), resourceController as MonoBehaviour); var item = this.loaded.FirstOrDefault(x => x.id == resource.GetId()); if (item != null) { if (item.references.Remove(resourceController as WindowComponent) == true) { this.loaded.RemoveAll(x => { if (x.id == resource.GetId() && x.references.Count == 0) { if (x.loadedObjectId < 0) { Object.Destroy(x.loadedObject); } return(true); } return(false); }); } } if (resetController == true) { var image = resourceController as IImageComponent; var source = image.GetImageSource(); if (source != null) { image.ResetImage(); resource.Unload(source.sprite); } else { var sourceRaw = image.GetRawImageSource(); if (sourceRaw != null) { image.ResetImage(); resource.Unload(sourceRaw.texture); } } } }
public void Dispose() { this.resource = null; this.component = null; //this.graphic = null; this.customResourcePath = null; this.onSuccess = null; this.onFailed = null; if (this.task != null) { this.task.Dispose(); this.task = null; } }
private Object Load_INTERNAL(string path, System.Type type) { //var watch = new System.Diagnostics.Stopwatch(); //watch.Start(); var pathHash = ResourceBase.GetJavaHash(path); var typeHash = ResourceBase.GetJavaHash(type.FullName); var resourceKey = ResourceBase.GetKey(pathHash, typeHash); Object output = null; if (output == null) { ResourceEntity entity; if (this.resources.TryGetValue(resourceKey, out entity) == true) { output = entity.resource; } } if (output == null) { var key = ResourceBase.GetKey(pathHash, 0); ResourceEntity entity; if (this.resources.TryGetValue(key, out entity) == true) { if (entity.resource is GameObject && type != typeof(GameObject)) { output = (entity.resource as GameObject).GetComponent(type); } else { output = entity.resource; } } } if (output == null) { output = Resources.Load(path, type); //this.resources.Add(resourceKey, new ResourceEntity() { resource = output }); } //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) Debug.Log(string.Format("Resource `{0}` got in {1}ms ({2} ticks)", path, watch.ElapsedMilliseconds, watch.ElapsedTicks)); //watch.Stop(); return(output); }
public ResourceBase(ResourceBase other) { this.async = other.async; this.assetPath = other.assetPath; this.assetBundleName = other.assetBundleName; this.resourcesPath = other.resourcesPath; this.webPath = other.webPath; this.loadableWeb = other.loadableWeb; this.loadableResource = other.loadableResource; this.loadableStream = other.loadableStream; this.loadableAssetBundle = other.loadableAssetBundle; this.multiObjects = other.multiObjects; this.objectIndex = other.objectIndex; this.multiObjectsAssetBundle = other.multiObjectsAssetBundle; this.objectIndexAssetBundle = other.objectIndexAssetBundle; this.customResourcePath = other.customResourcePath; this.readableTexture = other.readableTexture; this.id = other.id; this.cacheVersion = other.cacheVersion; this.streamingAssetsPathStandalone = other.streamingAssetsPathStandalone; this.streamingAssetsPathIOS = other.streamingAssetsPathIOS; this.streamingAssetsPathAndroid = other.streamingAssetsPathAndroid; this.streamingAssetsPathPS4 = other.streamingAssetsPathPS4; this.streamingAssetsPathXBOXONE = other.streamingAssetsPathXBOXONE; this.streamingAssetsPathCommon = other.streamingAssetsPathCommon; this.streamingAssetsPathStandaloneMovieAudio = other.streamingAssetsPathStandaloneMovieAudio; this.streamingAssetsPathIOSMovieAudio = other.streamingAssetsPathIOSMovieAudio; this.streamingAssetsPathAndroidMovieAudio = other.streamingAssetsPathAndroidMovieAudio; this.streamingAssetsPathPS4MovieAudio = other.streamingAssetsPathPS4MovieAudio; this.streamingAssetsPathXBOXONEMovieAudio = other.streamingAssetsPathXBOXONEMovieAudio; this.streamingAssetsPathCommonMovieAudio = other.streamingAssetsPathCommonMovieAudio; this.streamingAssetsPathStandaloneIsMovie = other.streamingAssetsPathStandaloneIsMovie; this.streamingAssetsPathIOSIsMovie = other.streamingAssetsPathIOSIsMovie; this.streamingAssetsPathAndroidIsMovie = other.streamingAssetsPathAndroidIsMovie; this.streamingAssetsPathPS4IsMovie = other.streamingAssetsPathPS4IsMovie; this.streamingAssetsPathXBOXONEIsMovie = other.streamingAssetsPathXBOXONEIsMovie; this.streamingAssetsPathCommonIsMovie = other.streamingAssetsPathCommonIsMovie; this.canBeUnloaded = other.canBeUnloaded; }
public void Dispose(ResourceBase resource) { resource.Unload(); //if (this.loaded == true && this.loadedObjectId < 0 && this.loadedObject != null) Object.Destroy(this.loadedObject); this.loadedObject = null; this.onObjectLoaded = null; this.references = null; this.id = 0; this.loaded = false; #if UNITY_EDITOR this.referencesCount = 0; #endif }
private bool IsLoaded <T>(WindowComponent reference, ResourceBase resource, out Item item, System.Action <T> callback) where T : Object { var itemInner = this.loaded.FirstOrDefault(x => x.id == resource.GetId() /*(x.@object == null || x.@object is T)*/); if (itemInner != null) { item = itemInner; if (itemInner.references.Contains(reference) == false) { itemInner.references.Add(reference); } else { //Debug.LogError("IsLoaded returns `true` but reference already in list.", reference); } if (itemInner.loaded == false) { System.Action callbackInner = null; callbackInner = () => { itemInner.onObjectLoaded -= callbackInner; callback.Invoke(itemInner.@object as T); }; itemInner.onObjectLoaded += callbackInner; } else { callback(itemInner.@object as T); } return(true); } item = new Item() { id = resource.GetId(), @object = null, loaded = false, references = new List <WindowComponent>() { reference } }; this.loaded.Add(item); return(false); }
private static bool RemoveIfRefsZero_INTERNAL(Item item, ResourceBase resource) { if (item == null || item.references == null || item.references.Count != 0) { return(false); } item.Dispose(resource); WindowSystemResources.instance.loaded.RemoveAll(x => { if (x.id == item.id) { return(true); } return(false); }); return(true); }
private void OnItemCallback_INTERNAL <T>(Item item, ResourceBase resource, System.Action <T> callbackLoaded, System.Action callbackFailed) /*where T : Object*/ { item.onObjectLoaded += (itemInner) => { if (WindowSystemResources.RemoveIfRefsZero_INTERNAL(itemInner, resource) == true) { return; } if (callbackLoaded != null) { callbackLoaded.Invoke((T)itemInner.loadedObject); } }; item.onObjectFailed += (itemInner) => { if (callbackFailed != null) { callbackFailed.Invoke(); } }; }
public ResourceBase(ResourceBase source) { this.async = source.async; this.controlType = source.controlType; this.assetPath = source.assetPath; this.resourcesPath = source.resourcesPath; this.loadableResource = source.loadableResource; this.loadableStream = source.loadableStream; this.multiObjects = source.multiObjects; this.objectIndex = source.objectIndex; this.customResourcePath = source.customResourcePath; this.id = source.id; this.loadedObject = source.loadedObject; this.loadedObjectId = source.loadedObjectId; this.loaded = source.loaded; this.streamingAssetsPathStandalone = source.streamingAssetsPathStandalone; this.streamingAssetsPathIOS = source.streamingAssetsPathIOS; this.streamingAssetsPathAndroid = source.streamingAssetsPathAndroid; this.streamingAssetsPathPS4 = source.streamingAssetsPathPS4; this.streamingAssetsPathXBOXONE = source.streamingAssetsPathXBOXONE; }
private void Unload_INTERNAL(IResourceReference resourceController, ResourceBase resource, bool resetController = true) { if (resetController == true) { var image = resourceController as IImageComponent; var source = image.GetImageSource(); if (source != null) { image.ResetImage(); //resource.Unload(); } else { var sourceRaw = image.GetRawImageSource(); if (sourceRaw != null) { image.ResetImage(); //resource.Unload(); } } } WindowSystemResources.UnloadResource_INTERNAL(resourceController, resource); }
private System.Collections.Generic.IEnumerator <byte> LoadResource_INTERNAL <T>(ResourceBase resource, IResourceReference component, string customResourcePath, System.Action <T> callback, bool async) /*where T : Object*/ { var task = new TaskItem(); task.id = resource.GetId(); task.async = async; task.resource = resource; task.component = component; task.customResourcePath = customResourcePath; task.onSuccess = (obj) => { T resultObj = default(T); if (obj is GameObject && typeof(T).HasBaseType(typeof(Component)) == true && typeof(T).HasBaseType(typeof(GameObject)) == false) { resultObj = (obj as GameObject).GetComponent <T>(); } else { //Debug.Log(typeof(T) + " << " + obj); resultObj = (T)obj; } callback.Invoke(resultObj); }; task.onFailed = () => { callback.Invoke(default(T)); }; this.tasks.Add(task); //Debug.Log("Resource Task: " + task.resource.assetPath); task.coroutine = this.StartTask <T>(task); while (task.coroutine.MoveNext() == true) { yield return(0); } task.Dispose(); this.tasks.Remove(task); }
public static void LoadCustom <T>(ResourceBase resource, System.Action <T> callback) where T : MonoBehaviour { WindowSystemResources.instance.LoadCustom_INTERNAL(resource, callback); }
public static System.Collections.Generic.IEnumerator <byte> LoadResource <T>(ResourceBase resource, IResourceReference component, string customResourcePath, System.Action <T> callback, bool async) /*where T : Object*/ { return(WindowSystemResources.instance.LoadResource_INTERNAL <T>(resource, component, customResourcePath, callback, async)); }
public static void Unload(ILoadableResource resourceController, ResourceBase resource, bool resetController = true) { WindowSystemResources.instance.Unload_INTERNAL(resourceController, resource, resetController); }
public static void Unload(ResourceBase resource, Object source) { resource.Unload(source); }
public virtual void Validate(Object item) { if (item == null) { return; } ME.EditorUtilities.SetValueIfDirty(ref this.assetPath, UnityEditor.AssetDatabase.GetAssetPath(item)); #region Resources { var resourcePath = (this.assetPath.Contains("/Resources/") == true ? this.assetPath.Split(new string[] { "/Resources/" }, System.StringSplitOptions.None)[1] : string.Empty); var ext = System.IO.Path.GetExtension(resourcePath); ME.EditorUtilities.SetValueIfDirty(ref this.resourcesPath, resourcePath.Substring(0, resourcePath.Length - ext.Length)); ME.EditorUtilities.SetValueIfDirty(ref this.loadableResource, (string.IsNullOrEmpty(this.resourcesPath) == false)); } #endregion #region StreamingAssets { var streamingAssetsPath = (this.assetPath.Contains("/StreamingAssets/") == true ? this.assetPath.Split(new string[] { "/StreamingAssets/" }, System.StringSplitOptions.None)[1] : string.Empty); var platformSplit = streamingAssetsPath.Split(new char[] { '/' }, System.StringSplitOptions.RemoveEmptyEntries); if (platformSplit.Length > 0) { var localPath = string.Join("/", platformSplit, 1, platformSplit.Length - 1); var localDir = System.IO.Path.GetDirectoryName(localPath); var filenameWithoutExt = System.IO.Path.GetFileNameWithoutExtension(streamingAssetsPath); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathIOS, this.GetPlatformDirectory(Platform.iOS, localDir, filenameWithoutExt)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathAndroid, this.GetPlatformDirectory(Platform.Android, localDir, filenameWithoutExt)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathStandalone, this.GetPlatformDirectory(Platform.Standalone, localDir, filenameWithoutExt)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathPS4, this.GetPlatformDirectory(Platform.PS4, localDir, filenameWithoutExt)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathXBOXONE, this.GetPlatformDirectory(Platform.XBOXONE, localDir, filenameWithoutExt)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathCommon, this.GetPlatformDirectory(Platform.Common, localDir, filenameWithoutExt)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathIOSMovieAudio, this.GetMovieAudio(this.streamingAssetsPathIOS)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathAndroidMovieAudio, this.GetMovieAudio(this.streamingAssetsPathAndroid)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathStandaloneMovieAudio, this.GetMovieAudio(this.streamingAssetsPathStandalone)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathPS4MovieAudio, this.GetMovieAudio(this.streamingAssetsPathPS4)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathXBOXONEMovieAudio, this.GetMovieAudio(this.streamingAssetsPathXBOXONE)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathCommonMovieAudio, this.GetMovieAudio(this.streamingAssetsPathCommon)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathIOSIsMovie, this.IsMovie(this.streamingAssetsPathIOS)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathAndroidIsMovie, this.IsMovie(this.streamingAssetsPathAndroid)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathStandaloneIsMovie, this.IsMovie(this.streamingAssetsPathStandalone)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathPS4IsMovie, this.IsMovie(this.streamingAssetsPathPS4)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathXBOXONEIsMovie, this.IsMovie(this.streamingAssetsPathXBOXONE)); ME.EditorUtilities.SetValueIfDirty(ref this.streamingAssetsPathCommonIsMovie, this.IsMovie(this.streamingAssetsPathCommon)); } ME.EditorUtilities.SetValueIfDirty(ref this.loadableStream, (string.IsNullOrEmpty(streamingAssetsPath) == false)); } #endregion #region AssetBundles var importer = UnityEditor.AssetImporter.GetAtPath(this.assetPath); ME.EditorUtilities.SetValueIfDirty(ref this.loadableAssetBundle, importer != null && string.IsNullOrEmpty(importer.assetBundleName) == false); if (this.loadableAssetBundle == true) { ME.EditorUtilities.SetValueIfDirty(ref this.assetBundleName, importer.assetBundleName); ME.EditorUtilities.SetValueIfDirty(ref this.loadableResource, false); ME.EditorUtilities.SetValueIfDirty(ref this.loadableStream, false); ME.EditorUtilities.SetValueIfDirty(ref this.multiObjectsAssetBundle, true); WindowSystemAssetBundlesMap map = null; var objects = UnityEditor.AssetDatabase.FindAssets("t:ScriptableObject"); for (int i = 0, size = objects.Length; i < size; ++i) { var path = UnityEditor.AssetDatabase.GUIDToAssetPath(objects[i]); if (path.Contains("WindowSystemAssetBundlesMap")) { map = UnityEditor.AssetDatabase.LoadAssetAtPath(path, typeof(WindowSystemAssetBundlesMap)) as WindowSystemAssetBundlesMap; break; } } if (map == null) { Debug.LogError("Missing WindowSystemAssetBundlesMap!"); } else { ME.EditorUtilities.SetValueIfDirty(ref this.objectIndexAssetBundle, map.GetIndex(this.assetBundleName, this.assetPath)); } } #endregion var uniquePath = (this.multiObjects == true) ? (string.Format("{0}#{1}", this.GetAssetPath(), this.objectIndex)) : this.GetAssetPath(); ME.EditorUtilities.SetValueIfDirty(ref this.id, ResourceBase.GetJavaHash(uniquePath)); ME.EditorUtilities.SetValueIfDirty(ref this.canBeUnloaded, ((item is GameObject) == false && (item is Component) == false)); }
public static long GetKey(ResourceBase resource, IImageComponent component) { return(resource.GetId()); }
public static void LoadResource <T>(ResourceBase resource, System.Action <T> callback, bool async) /*where T : Object*/ { Coroutines.Run(WindowSystemResources.instance.LoadResource_INTERNAL <T>(resource, component: null, customResourcePath: null, callback: callback, async: async)); }