private CPooledGameObjectScript CreateGameObject(string prefabFullPath, Vector3 pos, Quaternion rot, bool useRotation, enResourceType resourceType, string prefabKey) { CPooledGameObjectScript component = null; bool needCached = resourceType == enResourceType.BattleScene; GameObject content = Singleton <CResourceManager> .GetInstance().GetResource(prefabFullPath, typeof(GameObject), resourceType, needCached, false).m_content as GameObject; if (content == null) { return(null); } GameObject gameObject = null; if (useRotation) { gameObject = UnityEngine.Object.Instantiate(content, pos, rot) as GameObject; } else { gameObject = UnityEngine.Object.Instantiate(content) as GameObject; gameObject.transform.position = pos; } IPooledMonoBehaviour[] pooledMonoBehaviours = this.GetPooledMonoBehaviours(gameObject); DebugHelper.Assert(gameObject != null); component = gameObject.GetComponent <CPooledGameObjectScript>(); if (component == null) { component = gameObject.AddComponent <CPooledGameObjectScript>(); } component.m_prefabKey = prefabKey; component.m_pooledMonoBehaviours = pooledMonoBehaviours; component.m_defaultScale = component.transform.localScale; component.m_isInit = true; this.HandlePooledMonoBehaviour(component.m_pooledMonoBehaviours, enPooledMonoBehaviourAction.Create); return(component); }
public GameObject GetGameObject(string prefabFullPath, enResourceType resourceType) { bool isInit = false; return(this.GetGameObject(prefabFullPath, Vector3.zero, Quaternion.identity, false, resourceType, out isInit)); }
public GameObject GetGameObject(string prefabFullPath, Vector3 pos, Quaternion rot, enResourceType resourceType, out bool isInit) { return(this.GetGameObject(prefabFullPath, pos, rot, true, resourceType, out isInit)); }
private GameObject GetGameObject(string prefabFullPath, Vector3 pos, Quaternion rot, bool useRotation, enResourceType resourceType, out bool isInit) { string key = CFileManager.EraseExtension(prefabFullPath).ToLower(); Queue <CPooledGameObjectScript> queue = null; if (!this.m_pooledGameObjectMap.TryGetValue(key, out queue)) { queue = new Queue <CPooledGameObjectScript>(); this.m_pooledGameObjectMap.Add(key, queue); } CPooledGameObjectScript script = null; while (queue.Count > 0) { script = queue.Dequeue(); if ((script != null) && (script.gameObject != null)) { script.gameObject.transform.SetParent(null, true); script.gameObject.transform.position = pos; script.gameObject.transform.rotation = rot; script.gameObject.transform.localScale = script.m_defaultScale; break; } script = null; } if (script == null) { script = this.CreateGameObject(prefabFullPath, pos, rot, useRotation, resourceType, key); } if (script == null) { isInit = false; return(null); } isInit = script.m_isInit; script.gameObject.SetActive(true); this.HandlePooledMonoBehaviour(script.m_pooledMonoBehaviours, enPooledMonoBehaviourAction.Get); return(script.gameObject); }
private GameObject GetGameObject(string prefabFullPath, Vector3 pos, Quaternion rot, bool useRotation, enResourceType resourceType, out bool isInit) { string text = CFileManager.EraseExtension(prefabFullPath); Queue <CPooledGameObjectScript> queue = null; if (!this.m_pooledGameObjectMap.TryGetValue(text.JavaHashCodeIgnoreCase(), out queue)) { queue = new Queue <CPooledGameObjectScript>(); this.m_pooledGameObjectMap.Add(text.JavaHashCodeIgnoreCase(), queue); } CPooledGameObjectScript cPooledGameObjectScript = null; while (queue.get_Count() > 0) { cPooledGameObjectScript = queue.Dequeue(); if (cPooledGameObjectScript != null && cPooledGameObjectScript.gameObject != null) { cPooledGameObjectScript.gameObject.transform.SetParent(null, true); cPooledGameObjectScript.gameObject.transform.position = pos; cPooledGameObjectScript.gameObject.transform.rotation = rot; cPooledGameObjectScript.gameObject.transform.localScale = cPooledGameObjectScript.m_defaultScale; break; } cPooledGameObjectScript = null; } if (cPooledGameObjectScript == null) { cPooledGameObjectScript = this.CreateGameObject(prefabFullPath, pos, rot, useRotation, resourceType, text); } if (cPooledGameObjectScript == null) { isInit = false; return(null); } isInit = cPooledGameObjectScript.m_isInit; cPooledGameObjectScript.OnGet(); return(cPooledGameObjectScript.gameObject); }
private CPooledGameObjectScript CreateGameObject(string prefabFullPath, Vector3 pos, Quaternion rot, bool useRotation, enResourceType resourceType, string prefabKey) { bool needCached = resourceType == enResourceType.BattleScene; GameObject gameObject = Singleton <CResourceManager> .GetInstance().GetResource(prefabFullPath, typeof(GameObject), resourceType, needCached, false).m_content as GameObject; if (gameObject == null) { return(null); } GameObject gameObject2; if (useRotation) { gameObject2 = (Object.Instantiate(gameObject, pos, rot) as GameObject); } else { gameObject2 = (Object.Instantiate(gameObject) as GameObject); gameObject2.transform.position = pos; } DebugHelper.Assert(gameObject2 != null); CPooledGameObjectScript cPooledGameObjectScript = gameObject2.GetComponent <CPooledGameObjectScript>(); if (cPooledGameObjectScript == null) { cPooledGameObjectScript = gameObject2.AddComponent <CPooledGameObjectScript>(); } cPooledGameObjectScript.Initialize(prefabKey); cPooledGameObjectScript.OnCreate(); return(cPooledGameObjectScript); }
public CResource GetResource(string fullPathInResources, System.Type resourceContentType, enResourceType resourceType, bool needCached = false, bool unloadBelongedAssetBundleAfterLoaded = false) { if (string.IsNullOrEmpty(fullPathInResources)) { return(new CResource(string.Empty, string.Empty, null, resourceType, unloadBelongedAssetBundleAfterLoaded)); } string key = CFileManager.EraseExtension(fullPathInResources).ToLower(); CResource resource = null; if (this.m_cachedResourceMap.TryGetValue(key, out resource)) { if (resource.m_resourceType != resourceType) { resource.m_resourceType = resourceType; } return(resource); } resource = new CResource(key, fullPathInResources, resourceContentType, resourceType, unloadBelongedAssetBundleAfterLoaded); this.LoadResource(resource); if (needCached) { this.m_cachedResourceMap.Add(key, resource); } return(resource); }
public GameObject GetGameObject(string prefabFullPath, Vector3 pos, enResourceType resourceType) { bool flag = false; return(this.GetGameObject(prefabFullPath, pos, Quaternion.identity, false, resourceType, out flag)); }
public void LoadAllResourceInResourcePackerInfo(CResourcePackerInfo resourcePackerInfo, enResourceType resourceType) { if (resourcePackerInfo != null) { for (int i = 0; i < resourcePackerInfo.m_resourceInfos.Count; i++) { stResourceInfo info = resourcePackerInfo.m_resourceInfos[i]; stResourceInfo info2 = resourcePackerInfo.m_resourceInfos[i]; this.GetResource(info.m_fullPathInResourcesWithoutExtension, this.GetResourceContentType(info2.m_extension), resourceType, true, i == (resourcePackerInfo.m_resourceInfos.Count - 1)); } } }
public void LoadAllResourceInResourcePackerInfo(string fullPathInIFS, enResourceType resourceType) { this.LoadAllResourceInResourcePackerInfo(this.GetResourcePackerInfo(fullPathInIFS), resourceType); }
public static CResource GetResource(string fullPathInResources, Type resourceContentType, enResourceType resourceType, bool needCached = false, bool unloadBelongedAssetBundleAfterLoaded = false) { if (string.IsNullOrEmpty(fullPathInResources)) { return(new CResource(0, string.Empty, null, resourceType, unloadBelongedAssetBundleAfterLoaded)); } string s = CFileManager.EraseExtension(fullPathInResources); //int key = s.JavaHashCodeIgnoreCase(); int key = s.GetHashCode(); CResource resource = null; if (m_cachedResourceMap.TryGetValue(key, out resource)) { if (resource.m_resourceType != resourceType) { resource.m_resourceType = resourceType; } return(resource); } resource = new CResource(key, fullPathInResources, resourceContentType, resourceType, unloadBelongedAssetBundleAfterLoaded); try { LoadResource(resource); } catch (Exception exception) { object[] inParameters = new object[] { s }; //DebugHelper.Assert(false, "Failed Load Resource {0}", inParameters); throw exception; } if (needCached) { m_cachedResourceMap.Add(key, resource); } return(resource); }
private CPooledGameObjectScript CreateGameObject(string prefabFullPath, Vector3 pos, Quaternion rot, bool useRotation, enResourceType resourceType, string prefabKey) { CPooledGameObjectScript component = null; bool needCached = resourceType == enResourceType.BattleScene; GameObject content = Singleton <CResourceManager> .GetInstance().GetResource(prefabFullPath, typeof(GameObject), resourceType, needCached, false).m_content as GameObject; if (content == null) { return(null); } GameObject obj3 = null; if (useRotation) { obj3 = UnityEngine.Object.Instantiate(content, pos, rot) as GameObject; } else { obj3 = UnityEngine.Object.Instantiate(content) as GameObject; obj3.transform.position = pos; } DebugHelper.Assert(obj3 != null); component = obj3.GetComponent <CPooledGameObjectScript>(); if (component == null) { component = obj3.AddComponent <CPooledGameObjectScript>(); } component.Initialize(prefabKey); component.OnCreate(); return(component); }
public GameObject GetGameObject(string prefabFullPath, Vector3 pos, enResourceType resourceType, out bool isInit) { return(GetGameObject(prefabFullPath, pos, Quaternion.identity, false, resourceType, out isInit)); }
public GameObject GetGameObject(string prefabFullPath, Vector3 pos, Quaternion rot, enResourceType resourceType) { bool flag = false; return(GetGameObject(prefabFullPath, pos, rot, true, resourceType, out flag)); }
public CResource(string key, string fullPathInResources, System.Type contentType, enResourceType resourceType, bool unloadBelongedAssetBundleAfterLoaded) { this.m_key = key; this.m_fullPathInResources = fullPathInResources; this.m_fullPathInResourcesWithoutExtension = CFileManager.EraseExtension(this.m_fullPathInResources); this.m_name = CFileManager.EraseExtension(CFileManager.GetFullName(fullPathInResources)); this.m_resourceType = resourceType; this.m_state = enResourceState.Unload; this.m_contentType = contentType; this.m_unloadBelongedAssetBundleAfterLoaded = unloadBelongedAssetBundleAfterLoaded; this.m_content = null; this.m_isAbandon = false; }