IEnumerator CoroutineLoadTexture(string textureName, string texturePath) { LogParameter("加载Texture:", texturePath); using (UnityWebRequest request = new UnityWebRequest(texturePath)) { DownloadHandlerTexture downloadHandlerTexture = new DownloadHandlerTexture(true); request.downloadHandler = downloadHandlerTexture; yield return(request.SendWebRequest()); Texture localTexture = downloadHandlerTexture.texture; Textures.Add(textureName, localTexture); } waitForLoadResourceState.ReductionState(texturePath); }
IEnumerator CoroutineLoadBundle(string bundleName, string bundlePath) { LogParameter("加载AssetBundle:", bundlePath); AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(bundlePath); yield return(request); AssetBundle ab = request.assetBundle; AssetBundles.Add(bundleName, ab); waitForLoadBundleState.ReductionState(bundlePath); }
/// <summary> /// 加载xml文件 /// </summary> /// <param name="xmlName">xml文件名</param> /// <param name="xmlPath">xml在游戏目录下的完整路径</param> /// <returns></returns> IEnumerator CoroutineLoadXml(string xmlName, string xmlPath) { LogParameter("加载XML:", xmlName, xmlPath); using (UnityWebRequest www = new UnityWebRequest(xmlPath)) { www.downloadHandler = new DownloadHandlerBuffer(); yield return(www.SendWebRequest()); string text = RemoveUtf8ByteOrderMark(www.downloadHandler.text); XDocument xDoc = XDocument.Parse(text); XmlDocuments.Add(xmlName, xDoc); waitForLoadXmlState.ReductionState(xmlPath); } }
public void ReductionState(T token) { if (nextState.StateToken as object == token as object) { nextState = nextState.nextState; if (isFirst) { if (EachReduction != null) { EachReduction.Invoke(token); } if (nextState == null && addAlready) { MainReduction.Invoke(); } } } else { nextState.ReductionState(token); } }