using UnityEngine; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.AddressableAssets; using System.Collections; using System; public class Createmcx : MonoBehaviour { public static GameObject Mcx(string Name, float sx, float sy, float sz, float px, float py, float pz, float rx, float ry, float rz, string texscode) { //print("stove C[54]===3=" + texscode);//SPLA.1?F6F6F6?F6F6F6?F6F6F6?1?0?0.5?0.3?1 //Material MAT = CREATE.GetTextureMat(_G.GLOBAL[_G.G][9].Split(","[0])[0]); Material MAT = UIT_MATERIAL.GetMaterial(texscode); GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Cube); obj.GetComponent().enabled = false; obj.transform.localScale = new Vector3(sx, sy, sz); obj.transform.position = new Vector3(px, py, pz); obj.transform.rotation = Quaternion.Euler(rx, ry, rz); obj.GetComponent().material = MAT; DOIT.SetSizeTex(obj, 48, 48, 0, 0, 0, 0, 90, 90); obj.name = Name; string TextureName = texscode.Split("?")[0].Replace(",","?").Replace("_","?");; if (texscode.Split("?").Length > 3 && TextureName != "MELAMINEWHITE" && TextureName != "none") { StaticCoroutine.Start(GORETURN(obj, MAT,TextureName)); } return obj; } public static IEnumerator GORETURN(GameObject obj, Material MAT,string TextureName) { //print("TexName====" +TextureName); Addressables.LoadAssetAsync(TextureName).Completed += handle => { if (handle.Status == AsyncOperationStatus.Succeeded) { Texture2D tex = Instantiate(handle.Result); MAT.SetTexture("_Texture", tex); } else { Debug.LogError("Failed to load texture: " + obj.name); } }; yield return null; //new WaitForSeconds(2); } }