Ejemplo n.º 1
0
 // Token: 0x0600074C RID: 1868 RVA: 0x0003D084 File Offset: 0x0003B284
 private void Start()
 {
     this.mTrans  = base.transform;
     this.mUITex  = base.GetComponent <UITexture>();
     this.mCam    = UICamera.FindCameraForLayer(base.gameObject.layer);
     this.mWidth  = this.mUITex.width;
     this.mHeight = this.mUITex.height;
     Color[] array = new Color[this.mWidth * this.mHeight];
     for (int i = 0; i < this.mHeight; i++)
     {
         float y = ((float)i - 1f) / (float)this.mHeight;
         for (int j = 0; j < this.mWidth; j++)
         {
             float x   = ((float)j - 1f) / (float)this.mWidth;
             int   num = j + i * this.mWidth;
             array[num] = UIColorPicker.Sample(x, y);
         }
     }
     this.mTex = new Texture2D(this.mWidth, this.mHeight, TextureFormat.RGB24, false);
     this.mTex.SetPixels(array);
     this.mTex.filterMode = FilterMode.Trilinear;
     this.mTex.wrapMode   = TextureWrapMode.Clamp;
     this.mTex.Apply();
     this.mUITex.mainTexture = this.mTex;
     this.Select(this.value);
 }
Ejemplo n.º 2
0
 static public int Sample_s(IntPtr l)
 {
     try {
         System.Single a1;
         checkType(l, 1, out a1);
         System.Single a2;
         checkType(l, 2, out a2);
         var ret = UIColorPicker.Sample(a1, a2);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 3
0
    public Vector2 Select(Color c)
    {
        if (this.mUITex == null)
        {
            this.value = c;
            return(this.mPos);
        }
        float num = 3.40282347E+38f;

        for (int i = 0; i < this.mHeight; i++)
        {
            float y = ((float)i - 1f) / (float)this.mHeight;
            for (int j = 0; j < this.mWidth; j++)
            {
                float x      = ((float)j - 1f) / (float)this.mWidth;
                Color color  = UIColorPicker.Sample(x, y);
                Color color2 = color;
                color2.r -= c.r;
                color2.g -= c.g;
                color2.b -= c.b;
                float num2 = color2.r * color2.r + color2.g * color2.g + color2.b * color2.b;
                if (num2 < num)
                {
                    num         = num2;
                    this.mPos.x = x;
                    this.mPos.y = y;
                }
            }
        }
        if (this.selectionWidget != null)
        {
            Vector3[] localCorners = this.mUITex.localCorners;
            Vector3   vector;
            vector.x = Mathf.Lerp(localCorners[0].x, localCorners[2].x, this.mPos.x);
            vector.y = Mathf.Lerp(localCorners[0].y, localCorners[2].y, this.mPos.y);
            vector.z = 0f;
            vector   = this.mTrans.TransformPoint(vector);
            this.selectionWidget.transform.OverlayPosition(vector, this.mCam.cachedCamera);
        }
        this.value            = c;
        UIColorPicker.current = this;
        EventDelegate.Execute(this.onChange);
        UIColorPicker.current = null;
        return(this.mPos);
    }
Ejemplo n.º 4
0
    public Vector2 Select(Color c)
    {
        if (this.mUITex == (UnityEngine.Object)null)
        {
            this.value = c;
            return(this.mPos);
        }
        Single num = Single.MaxValue;

        for (Int32 i = 0; i < this.mHeight; i++)
        {
            Single y = ((Single)i - 1f) / (Single)this.mHeight;
            for (Int32 j = 0; j < this.mWidth; j++)
            {
                Single x      = ((Single)j - 1f) / (Single)this.mWidth;
                Color  color  = UIColorPicker.Sample(x, y);
                Color  color2 = color;
                color2.r -= c.r;
                color2.g -= c.g;
                color2.b -= c.b;
                Single num2 = color2.r * color2.r + color2.g * color2.g + color2.b * color2.b;
                if (num2 < num)
                {
                    num         = num2;
                    this.mPos.x = x;
                    this.mPos.y = y;
                }
            }
        }
        if (this.selectionWidget != (UnityEngine.Object)null)
        {
            Vector3[] localCorners = this.mUITex.localCorners;
            Vector3   vector;
            vector.x = Mathf.Lerp(localCorners[0].x, localCorners[2].x, this.mPos.x);
            vector.y = Mathf.Lerp(localCorners[0].y, localCorners[2].y, this.mPos.y);
            vector.z = 0f;
            vector   = this.mTrans.TransformPoint(vector);
            this.selectionWidget.transform.OverlayPosition(vector, this.mCam.cachedCamera);
        }
        this.value            = c;
        UIColorPicker.current = this;
        EventDelegate.Execute(this.onChange);
        UIColorPicker.current = (UIColorPicker)null;
        return(this.mPos);
    }
Ejemplo n.º 5
0
 // Token: 0x06000752 RID: 1874 RVA: 0x0003D3D8 File Offset: 0x0003B5D8
 public void Select(Vector2 v)
 {
     v.x       = Mathf.Clamp01(v.x);
     v.y       = Mathf.Clamp01(v.y);
     this.mPos = v;
     if (this.selectionWidget != null)
     {
         Vector3[] localCorners = this.mUITex.localCorners;
         v.x = Mathf.Lerp(localCorners[0].x, localCorners[2].x, this.mPos.x);
         v.y = Mathf.Lerp(localCorners[0].y, localCorners[2].y, this.mPos.y);
         v   = this.mTrans.TransformPoint(v);
         this.selectionWidget.transform.OverlayPosition(v, this.mCam.cachedCamera);
     }
     this.value            = UIColorPicker.Sample(this.mPos.x, this.mPos.y);
     UIColorPicker.current = this;
     EventDelegate.Execute(this.onChange);
     UIColorPicker.current = null;
 }
Ejemplo n.º 6
0
    // Token: 0x06000751 RID: 1873 RVA: 0x0003D264 File Offset: 0x0003B464
    private void Sample()
    {
        Vector3 vector = this.mTrans.InverseTransformPoint(UICamera.lastWorldPosition);

        Vector3[] localCorners = this.mUITex.localCorners;
        this.mPos.x = Mathf.Clamp01((vector.x - localCorners[0].x) / (localCorners[2].x - localCorners[0].x));
        this.mPos.y = Mathf.Clamp01((vector.y - localCorners[0].y) / (localCorners[2].y - localCorners[0].y));
        if (this.selectionWidget != null)
        {
            vector.x = Mathf.Lerp(localCorners[0].x, localCorners[2].x, this.mPos.x);
            vector.y = Mathf.Lerp(localCorners[0].y, localCorners[2].y, this.mPos.y);
            vector   = this.mTrans.TransformPoint(vector);
            this.selectionWidget.transform.OverlayPosition(vector, this.mCam.cachedCamera);
        }
        this.value            = UIColorPicker.Sample(this.mPos.x, this.mPos.y);
        UIColorPicker.current = this;
        EventDelegate.Execute(this.onChange);
        UIColorPicker.current = null;
    }
Ejemplo n.º 7
0
 public unsafe static long $Invoke4(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UIColorPicker.Sample(*(float *)args, *(float *)(args + 1))));
 }