public IEnumerator CreatePrefabCacheAsysc <T>(ePath path, string prefabName, int preloadCount, System.Action <int> completed) where T : Component { GameObject gameObject = null; yield return(LoadActorAsysc(path, prefabName, resource => { gameObject = resource; })); int resultCode = -1; if (gameObject != null) { resultCode = CreatePoolCache <T>(gameObject, false, preloadCount); if (completed != null) { completed(resultCode); } } else { if (completed != null) { completed(resultCode); } } }
public PrefabResource CreateUIResource(string prefabName, ePath pathType, bool dontDestroyOnLoad) { IResource res = FindResource(eResourceType.UI, prefabName); if (res != null) { return((PrefabResource)res); } return((PrefabResource)CreateResource(eResourceType.UI, prefabName, pathType)); }
public PrefabResource CreatePrefabResource(string prefabName, ePath pathType) { IResource res = FindResource(eResourceType.Prefab, prefabName); if (res != null) { return((PrefabResource)res); } return((PrefabResource)CreateResource(eResourceType.Prefab, prefabName, pathType)); }
public SpriteAssetResource CreateSpriteAssetResource(ePath ePath, string name, bool assetbundle) { IResource res = null; res = FindResource(eResourceType.SpriteAsset, name.ToLower()); if (res != null) { return((SpriteAssetResource)res); } return((SpriteAssetResource)MakeSpriteResource(eResourceType.SpriteAsset, ePath, name.ToLower())); }
public BreadthFirstSearchRadius(Pos start, RadiusRange radius, int maxIter = 100000) { _start = start; _range = radius._range; _type = radius._path; _maxIter = maxIter; _fastestPath = new Dictionary <Pos, Pos>(); _distanceFromStart = new Dictionary <Pos, float>(); _searched = new List <Pos>(); }
public SpriteResource CreateSpriteResource(string name, ePath ePath, bool assetbundle) { IResource res = FindResource(eResourceType.Sprite, name.ToLower()); if (res != null) { return(res as SpriteResource); } res = MakeSpriteResource(eResourceType.Sprite, ePath, name.ToLower()); return((SpriteResource)res); }
public SoundResource CreateSoundResource(string name, ePath ePath) { IResource res = null; res = FindResource(eResourceType.Sound, name); if (res != null) { return((SoundResource)res); } return((SoundResource)CreateResource(eResourceType.Sound, name, ePath)); }
public IEnumerator CreatePrefabResourceAsync(ePath path, string prefabName, System.Action <PrefabResource> action) { IResource res = FindResource(eResourceType.Prefab, prefabName); if (res != null) { action(res as PrefabResource); } else { yield return(CreateResourceAsync(eResourceType.Prefab, prefabName, path, result => { action(result as PrefabResource); })); } }
private GameObject LoadPrefab(ePath path, string prefabName) { if (string.IsNullOrEmpty(prefabName)) { return(null); } PrefabResource resource = Global.ResourceMgr.CreatePrefabResource(prefabName, path); if (resource != null) { return(resource.ResourceGameObject); } return(null); }
public IEnumerator CreateUIResourceAsync(string prefabName, ePath pathType, bool dontDestroyOnLoad, System.Action <PrefabResource> action) { IResource res = FindResource(eResourceType.UI, prefabName); if (res != null) { action(res as PrefabResource); } else { yield return(CreateResourceAsync(eResourceType.UI, prefabName, pathType, result => { action(result as PrefabResource); })); } }
public PrefabResource CreateGameResource(string name, ePath ePath) { IResource res = null; // if (ePath == E_Path.Sprite) // { // return CreateSpriteResource(name, ePath); // } res = FindResource(eResourceType.Prefab, name); if (res != null) { return((PrefabResource)res); } return((PrefabResource)CreateResource(eResourceType.Prefab, name, ePath)); }
private IEnumerator LoadActorAsysc(ePath path, string prefabName, System.Action <GameObject> action) { if (string.IsNullOrEmpty(prefabName)) { if (action != null) { action(null); } yield break; } PrefabResource prefabResource = null; yield return(Global.ResourceMgr.CreatePrefabResourceAsync(path, prefabName, resource => { if (action != null) { prefabResource = resource; action(prefabResource != null ? resource.ResourceGameObject : null); } })); }
private IResource CreateResource(eResourceType eType, string name, ePath ePath) { // 사운드는 넘어오는 name이 실제 파일 이름이 아니라 내부 이름이므로 변경 프로세스가 필요 // if (eType == E_ResourceType.Sound) // { // SoundInfo si; // if (DataManager.Instance.GetScriptData<SoundData>(E_GameScriptData.Sound).GetSoundInfo(name, out si)) // { // name = si.Filename; // } // } bool isAssetBundle = false; string path = StringUtil.Format("{0}/{1}", m_pathManager.GetPath(ePath), name); //string path = m_pathManager.GetPath(ePath) + name; Object objresource = Resources.Load(path); if (objresource == null) { return(null); } return(CreateResource(eType, name, path, objresource, isAssetBundle)); }
private IResource MakeSpriteResource(eResourceType eType, ePath ePath, string name) { string path = StringUtil.Format("{0}/{1}", m_pathManager.GetPath(ePath), name); Sprite[] allresource = null; Object obj = null; Object autotile = null; SpritePackerAsset spritePackerAsset = null; if (ePath == Resource.ePath.MapAutoTile) { obj = Resources.Load(path); string autotilepath = m_pathManager.GetPath(ePath) + "AutoTile"; autotile = Resources.Load(autotilepath); if (obj is SpritePackerAsset) { spritePackerAsset = (SpritePackerAsset)obj; allresource = spritePackerAsset.AllSprites; } } if (ePath == Resource.ePath.UISprite) { obj = Resources.Load(path); } else if (ePath == Resource.ePath.MapAsset || ePath == Resource.ePath.MapAutoAsset || ePath == Resource.ePath.MapActorAsset) { obj = Resources.Load(path); if (obj is SpritePackerAsset) { spritePackerAsset = (SpritePackerAsset)obj; allresource = spritePackerAsset.AllSprites; } } else { allresource = Resources.LoadAll <Sprite>(path); } IResource resource = null; if (eType == eResourceType.SpriteAsset) { if (obj == null) { Debug.LogError("TileSprite MakeSpriteResource name error" + name); return(null); } resource = new SpritePackerResource(spritePackerAsset, spritePackerAsset.AllSprites, false); } else if (eType == eResourceType.Sprite) { if (obj == null) { Debug.LogError("UISprite MakeSpriteResource name error" + name); return(null); } resource = new SpriteResource(obj, false); } else { if (allresource == null) { Debug.LogError("SpriteResource name error" + name); return(null); } resource = new SpritePackerResource(spritePackerAsset, allresource, false); } string[] split = path.Split('/'); string resourcename = split[split.Length - 1]; resource.InitLoad(resourcename, path); Dictionary <int, IResource> dicRes = GetDicResource(eType); if (dicRes.ContainsKey(resource.GetHashCode())) { Debug.LogError("MakeSpriteResource name error" + name); } else { dicRes.Add(resource.GetHashCode(), resource); } return(resource); }
public string GetPath(ePath eType) { return(m_dicPath[eType]); }
public int CreatePoolCache(ePath path, string prefabName, int preloadCount, int capacity) { GameObject gameObject = LoadPrefab(path, prefabName); return(CreatePoolCache(gameObject, preloadCount, capacity)); }
public T CreatePoolComponent <T>(ePath path, string prefabName, Vector3 position, Quaternion rotation, Transform parentTransform, bool active = true) where T : Component { GameObject gameObject = LoadPrefab(path, prefabName); return(CreatePoolComponent <T>(gameObject, position, rotation, parentTransform, active)); }
public IEnumerator CreateResourceAsync(eResourceType resourceType, string resourceName, ePath pathType, System.Action <IResource> action) { if (string.IsNullOrEmpty(resourceName) == true) { action(null); yield break; } bool isAssetBundle = false; string resourcePath = StringUtil.Format("{0}/{1}", m_pathManager.GetPath(pathType), resourceName); UnityEngine.Object resourceData = null; ResourceRequest request = Resources.LoadAsync(resourcePath); yield return(request); resourceData = request.asset; if (resourceData == null) { LogError("resource is null: " + resourceType.ToString() + ", " + pathType.ToString() + ", " + resourceName); action(null); yield break; } action(CreateResource(resourceType, resourceName, resourcePath, resourceData, isAssetBundle)); }
public RadiusRange(ePath path, float range) { _path = path; _range = range; }