public void AddMonitor(TextureHolderBase textureHolderBase) { var go = GameObject.Instantiate(prefab) as GameObject; go.transform.SetParent(contentSizeFitter.transform, false); var component = go.GetComponent <MonitorView>(); component.Init(textureHolderBase.gameObject.name, textureHolderBase, gridLayoutGroup.cellSize); component.ClickEvent += OnSelected; MonitorViews.Add(component); }
public void Init(string label, TextureHolderBase textureHolder, Vector2 size) { var rectTransform = GetComponent <RectTransform>(); this.label.text = label; rawImage.texture = textureHolder.GetTexture(); this.textureHolder = textureHolder; this.size = size; textureHolder.TextureInitializedEvent += TextureOwner_ChangeTextureEvent; Fit(); }
private void TextureOwner_ChangeTextureEvent(TextureHolderBase sender, Texture texture) { rawImage.texture = textureHolder.GetTexture(); Fit(); }