using System.Collections; using System.Collections.Generic; using UnityEngine; public class RetroLetto : MonoBehaviour { // Start is called before the first frame update static GameObject retro, cameretta, parete, pezzi; static Vector3 sSP1, sRL, pRL, sP; static MeshRenderer render; static Material mat; static string nome; static internal void Start() { retro = GameObject.Find("RetroLetto"); cameretta = GameObject.Find("Cameretta"); parete = GameObject.Find("parete 1"); sP = parete.transform.localScale; sSP1 = cameretta.transform.localScale; sRL = retro.transform.localScale = new Vector3(5, 190, 270); int i = 0; while (i < 5) { i++; pezzi = GameObject.CreatePrimitive(PrimitiveType.Cube); nome = "pezzoRL"; pezzi.name = $"{nome} {i}"; } Cameretta.ok(); //pRL = Cameretta.PosizionaObjectMain(retro.name, sRL, new Vector3(), sSP1, new string[] {"+", "+", "-"}); pRL.x += (sSP1.x / 2) - (sRL.x / 2) - sP.x; pRL.y += (sSP1.y / 2) + (sRL.y / 2); pRL.z += (sSP1.z / 2) - (sRL.z / 2) - 70; pRL = retro.transform.position = new Vector3(pRL.x, pRL.y, pRL.z); // Settaggio Colore RetroLetto render = retro.GetComponent(); mat = Resources.Load($"Color/ColorRL", typeof(Material)) as Material; render.material = mat; int l = 0; int space = 0; while (l < i) // Posizionamento pezzi del RetroLetto { space += 30; l++; pezzi = GameObject.Find($"{nome} {l}"); sRL = pezzi.transform.localScale = new Vector3(2, 3, 270); pRL = new Vector3(); pRL.x += (sSP1.x / 2) - (sRL.x / 2) - sP.x - retro.transform.localScale.x + 1.5f; pRL.y += (sSP1.y / 2) + (sRL.y / 2) + 10 + space; pRL.z += (sSP1.z / 2) - (sRL.z / 2) - 70; pRL = pezzi.transform.position = new Vector3(pRL.x, pRL.y, pRL.z); // Settaggio colore pezzi RetroLetto render = pezzi.GetComponent(); mat = Resources.Load($"Color/ColorPZ", typeof(Material)) as Material; render.material = mat; } // Settaggio colore RetroLetto render = retro.GetComponent(); mat = Resources.Load($"Color/ColorRL", typeof(Material)) as Material; render.material = mat; Debug.LogFormat($"{retro.name} {sSP1} {pRL} {sP.x}"); // Settaggio colore parete 1 render = parete.GetComponent(); mat = Resources.Load($"Color/ColorP1", typeof(Material)) as Material; render.material = mat; Debug.LogFormat($"{render}"); Scrivania.Start(); } // Update is called once per frame void Update() { } }