public void Initiate(Texture2D imageTuto, PauseTuto instancePauseTuto) { this.imageTuto = imageTuto; this.instancePT = instancePauseTuto; GetComponent <Button>().onClick.AddListener(this.ActionClick); this.GetComponent <RawImage>().texture = imageTuto; }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } scriptTuto = ScriptTutoObject.GetComponent <PauseTuto>(); }
public void CreateListPanel() { float padding = 210f; PauseTuto instancePT = ObjectPauseTuto.GetComponent <PauseTuto>(); ListScrollTutos.GetComponent <RectTransform>().sizeDelta = new Vector2(0, padding * instancePT.ImagesTuto.Count); ListScrollTutos.transform.localPosition += new Vector3(0, (instancePT.ImagesTuto.Count * padding) / 2, 0); float y = (instancePT.ImagesTuto.Count * padding) / 2 + padding / 2; foreach (var textureImage in instancePT.ImagesTuto) { y -= padding; GameObject tutoItem = Instantiate(PrefabTutoItem, ListScrollTutos.transform); tutoItem.transform.localScale = new Vector3(1f, 1f, 1f); tutoItem.transform.localPosition = new Vector3(0, y, 0); //set attributes tutoItem.GetComponent <ScriptButtonTutoItem>().Initiate(textureImage, ObjectPauseTuto.GetComponent <PauseTuto>()); } }