using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; public class ConstructStool : MonoBehaviour { static GameObject S; static int nO; public static void AddStool(int NO) { _G.Load = false; Get.o2("HIDER", "LoadingCircle").SetActive(true); nO = NO; Addressables.InstantiateAsync(_G.OBJs[nO][1]).Completed += Face_Completed; } public static void AddStoolPaint() { //print("name of Object==_3"+_G.OBJs[nO][0]); 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]; Bounds mapBounds = new (S.transform.position, Vector3.one); foreach(Transform child in S.transform) { mapBounds.Encapsulate(child.gameObject.GetComponent().bounds); } //Model 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; // S.AddComponent(); // var center = S.GetComponent().bounds.center; // var offset = new Vector3(center.x,center.y, center.z); // S.transform.localPosition -= offset*2; GameObject c1; GameObject c2; c1 = BASE.transform.Find("S1").transform.GetChild(0).gameObject; c2 = BASE.transform.Find("S1").transform.GetChild(1).gameObject; if(C[0].IndexOf("stoo")!=-1){ c1.GetComponent().material=MatA; c1.GetComponent().probeAnchor = ReflectionProbesUpdater.ReflectionStainless.transform; c2.GetComponent().material=MatB; c2.GetComponent().probeAnchor = ReflectionProbesUpdater.ReflectionStainless.transform; } Mesure.Addpoints("STOOL",BASE); //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 = _G.INV;//Resources.Load("MATERIALS/INVISIBLE") as Material; //BM.INV; BASE.transform.parent = SceneModeManager.Scene; } private static void Face_Completed(AsyncOperationHandle handle) { if (handle.Status == AsyncOperationStatus.Succeeded) { S = handle.Result; AddStoolPaint(); GameObject.Find("HIDER").transform.Find("LoadingCircle").gameObject.SetActive(false); _G.Load = true; } } }