using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; public class ConstructSmallelectro : MonoBehaviour { static GameObject S; static int nO; public static void AddSmallElectro(int NO) { _G.Load = false; GameObject.Find("HIDER").transform.Find("LoadingCircle").gameObject.SetActive(true); nO = NO; Addressables.InstantiateAsync(_G.OBJs[nO][1]).Completed += face_Completed; } public static void AddSmallElectroPaint() { string[] C = _G.OBJs[nO]; float w = DOIT.ConvertStringToNumber(C[6]); float h = DOIT.ConvertStringToNumber(C[7]); float d = DOIT.ConvertStringToNumber(C[8]); float px = DOIT.ConvertStringToNumber(C[15]); float py = DOIT.ConvertStringToNumber(C[16]); float pz = DOIT.ConvertStringToNumber(C[17]); float rx = DOIT.ConvertStringToNumber(C[18]); float ry = DOIT.ConvertStringToNumber(C[19]); float rz = DOIT.ConvertStringToNumber(C[20]); Material MatA=UIT_MATERIAL.GetMaterial(C[60]); Material MatB=UIT_MATERIAL.GetMaterial(C[61]); ////create BASE GameObject BASE = GameObject.CreatePrimitive(PrimitiveType.Cube);//new GameObject(); BASE.transform.localScale = new Vector3(w + 0.5f, h + 0.5f, d + 0.5f); BASE.name = C[0]; BASE.transform.parent = GameObject.Find("SCENE").transform; Destroy(GameObject.Find("New Game Object")); //Model //GameObject S = Instantiate(Resources.Load("OBJECTS/SMALL/" + C[1], typeof(GameObject))) as GameObject; S.transform.localRotation = Quaternion.Euler(0, 0, 0); float sw = DOIT.ConvertStringToNumber(_OL.GetValue(C[1],"w")); float sh = DOIT.ConvertStringToNumber(_OL.GetValue(C[1],"h")); float sd = DOIT.ConvertStringToNumber(_OL.GetValue(C[1],"d")); S.transform.localScale = new Vector3(w / sw, h / sh, d / sd); S.name = "S1"; S.transform.parent = BASE.transform; GameObject c1 = BASE.transform.Find("S1").transform.Find("C1").gameObject; GameObject c2 = BASE.transform.Find("S1").transform.Find("C2").gameObject; for (int i = 0; i < c1.transform.childCount; i++) { c1.transform.GetChild(i).GetComponent().material = MatA; //c1.transform.GetChild(i).GetComponent().probeAnchor = GameObject.Find("Reflection Stainless").transform; } for (int i = 0; i < c2.transform.childCount; i++) { c2.transform.GetChild(i).GetComponent().material = MatB; //c2.transform.GetChild(i).GetComponent().probeAnchor = GameObject.Find("Reflection Stainless").transform; } //Stet in scene BASE.transform.position = new Vector3(px, py, pz); BASE.transform.localRotation = Quaternion.Euler(rx, ry, rz); BASE.AddComponent(typeof(MoveObject)); BASE.GetComponent().material = Resources.Load("MATERIALS/INVISIBLE") as Material; //BM.INV; } private static void face_Completed(AsyncOperationHandle handle) { if (handle.Status == AsyncOperationStatus.Succeeded) { S = handle.Result; AddSmallElectroPaint(); GameObject.Find("HIDER").transform.Find("LoadingCircle").gameObject.SetActive(false); _G.Load = true; } } }