/// <summary> /// Sets the palette. /// </summary> /// <param name="value">Value.</param> protected virtual void SetPalette(Image value) { if (dragListener != null) { dragListener.OnDragEvent.RemoveListener(OnDrag); } if (clickListener != null) { clickListener.ClickEvent.RemoveListener(OnDrag); } if (resizeListener != null) { resizeListener.OnResize.RemoveListener(UpdateView); } palette = value; if (palette != null) { paletteRect = palette.transform as RectTransform; dragListener = Utilites.GetOrAddComponent <OnDragListener>(palette); dragListener.OnDragEvent.AddListener(OnDrag); clickListener = Utilites.GetOrAddComponent <ClickListener>(palette); clickListener.ClickEvent.AddListener(OnDrag); resizeListener = Utilites.GetOrAddComponent <ResizeListener>(palette); resizeListener.OnResize.AddListener(UpdateView); UpdateMaterial(); } else { paletteRect = null; } }
/// <summary> /// Sets the palette. /// </summary> /// <param name="value">Value.</param> protected virtual void SetImage(Image value) { if (dragListener != null) { dragListener.OnDragEvent.RemoveListener(OnDrag); } image = value; if (image != null) { imageRect = image.transform as RectTransform; dragListener = Utilites.GetOrAddComponent <OnDragListener>(image); dragListener.OnDragEvent.AddListener(OnDrag); clickListener = Utilites.GetOrAddComponent <ClickListener>(image); clickListener.ClickEvent.AddListener(OnDrag); } else { imageRect = null; } }