public override void Initial(FakeStruct fake, UIElement element) { base.Initial(fake, element); palette = new Palette(); callBackR = element.RegEvent <UserEvent>(); callBackR.IsCircular = true; callBackR.Drag = callBackR.DragEnd = DragingR; callBackR.PointerDown = PointDownR; var mod = element.transform; NobA = mod.Find("NobA"); NobB = mod.Find("NobB"); hc = mod.Find("HTemplate"); template = hc.GetComponent <HImage>(); callBackC = template.RegEvent <UserEvent>(); callBackC.Drag = callBackC.DragEnd = DragingC; callBackC.PointerDown = PointDownC; htemp = mod.GetComponent <HImage>(); htemp.MainTexture = Palette.LoadCTemplateAsync(); template.MainTexture = palette.texture; palette.AwaitLoadHSVT(1); SelectColor.a = 1; var son = mod.Find("Slider"); slider = son.GetComponent <HImage>(); slider.MainTexture = Palette.AlphaTemplate(); uISlider = slider.composite as UISlider; uISlider.OnValueChanged = AlphaChanged; uISlider.Percentage = 1; }
void PointDownR(UserEvent back, UserAction action) { float x = action.CanPosition.x - back.GlobalPosition.x; float y = action.CanPosition.y - back.GlobalPosition.y; x /= back.GlobalScale.x; y /= back.GlobalScale.y; float sx = x * x + y * y; float r = Mathf.Sqrt(220 * 220 / sx); x *= r; y *= r; if (NobA != null) { NobA.localPosition = new Vector3(x, y, 0); } float al = MathH.atan(-x, -y); palette.AwaitLoadHSVT(al / 360); Color col = palette.buffer[Index]; SelectColor.r = col.r; SelectColor.g = col.g; SelectColor.b = col.b; if (TemplateChanged != null) { TemplateChanged(this); } }
public override void Initial(FakeStruct fake, UIElement element, UIInitializer initializer) { base.Initial(fake, element, initializer); palette = new Palette(); callBackR = element.RegEvent <UserEvent>(new UICircleCollider()); callBackR.Drag = callBackR.DragEnd = DragingR; callBackR.PointerDown = PointDownR; NobA = element.Find("NobA"); NobB = element.Find("NobB"); hc = element.Find("HTemplate"); template = hc as HImage; callBackC = template.RegEvent <UserEvent>(); callBackC.Drag = callBackC.DragEnd = DragingC; callBackC.PointerDown = PointDownC; htemp = element as HImage; htemp.MainTexture = Palette.LoadCTemplateAsync(); template.MainTexture = palette.texture; palette.AwaitLoadHSVT(1); SelectColor.a = 1; var son = element.Find("Slider"); slider = son as HImage; slider.MainTexture = Palette.AlphaTemplate(); uISlider = slider.composite as UISlider; uISlider.OnValueChanged = AlphaChanged; uISlider.Percentage = 1; }