// Token: 0x06000246 RID: 582 RVA: 0x00018BAC File Offset: 0x00016DAC
    public GameObject Get(Vector3 myDir, float x = 1f, float y = 1f)
    {
        Transform transform = base.transform;

        myDir = transform.TransformDirection(myDir);
        Vector3    center = UIKeyNavigation.GetCenter(base.gameObject);
        float      num    = float.MaxValue;
        GameObject result = null;

        for (int i = 0; i < UIKeyNavigation.list.size; i++)
        {
            UIKeyNavigation uikeyNavigation = UIKeyNavigation.list.buffer[i];
            if (!(uikeyNavigation == this) && uikeyNavigation.constraint != UIKeyNavigation.Constraint.Explicit && uikeyNavigation.isColliderEnabled)
            {
                UIWidget component = uikeyNavigation.GetComponent <UIWidget>();
                if (!(component != null) || component.alpha != 0f)
                {
                    Vector3 direction = UIKeyNavigation.GetCenter(uikeyNavigation.gameObject) - center;
                    if (Vector3.Dot(myDir, direction.normalized) >= 0.707f)
                    {
                        direction    = transform.InverseTransformDirection(direction);
                        direction.x *= x;
                        direction.y *= y;
                        float sqrMagnitude = direction.sqrMagnitude;
                        if (sqrMagnitude <= num)
                        {
                            result = uikeyNavigation.gameObject;
                            num    = sqrMagnitude;
                        }
                    }
                }
            }
        }
        return(result);
    }
Esempio n. 2
0
    public GameObject Get(Vector3 myDir, float x = 1f, float y = 1f)
    {
        //IL_0001: Unknown result type (might be due to invalid IL or missing references)
        //IL_0006: Expected O, but got Unknown
        //IL_0008: Unknown result type (might be due to invalid IL or missing references)
        //IL_0009: Unknown result type (might be due to invalid IL or missing references)
        //IL_000e: Unknown result type (might be due to invalid IL or missing references)
        //IL_0011: Unknown result type (might be due to invalid IL or missing references)
        //IL_0016: Expected O, but got Unknown
        //IL_0016: Unknown result type (might be due to invalid IL or missing references)
        //IL_001b: Unknown result type (might be due to invalid IL or missing references)
        //IL_0093: Unknown result type (might be due to invalid IL or missing references)
        //IL_0098: Expected O, but got Unknown
        //IL_0098: Unknown result type (might be due to invalid IL or missing references)
        //IL_009d: Unknown result type (might be due to invalid IL or missing references)
        //IL_009e: Unknown result type (might be due to invalid IL or missing references)
        //IL_00a3: Unknown result type (might be due to invalid IL or missing references)
        //IL_00a5: Unknown result type (might be due to invalid IL or missing references)
        //IL_00a8: Unknown result type (might be due to invalid IL or missing references)
        //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
        //IL_00c8: Unknown result type (might be due to invalid IL or missing references)
        //IL_00cd: Unknown result type (might be due to invalid IL or missing references)
        //IL_0105: Unknown result type (might be due to invalid IL or missing references)
        //IL_010a: Expected O, but got Unknown
        Transform val = this.get_transform();

        myDir = val.TransformDirection(myDir);
        Vector3    center = GetCenter(this.get_gameObject());
        float      num    = 3.40282347E+38f;
        GameObject result = null;

        for (int i = 0; i < list.size; i++)
        {
            UIKeyNavigation uIKeyNavigation = list[i];
            if (!(uIKeyNavigation == this) && uIKeyNavigation.constraint != Constraint.Explicit && uIKeyNavigation.isColliderEnabled)
            {
                UIWidget component = uIKeyNavigation.GetComponent <UIWidget>();
                if (!(component != null) || component.alpha != 0f)
                {
                    Vector3 val2 = GetCenter(uIKeyNavigation.get_gameObject()) - center;
                    float   num2 = Vector3.Dot(myDir, val2.get_normalized());
                    if (!(num2 < 0.707f))
                    {
                        val2    = val.InverseTransformDirection(val2);
                        val2.x *= x;
                        val2.y *= y;
                        float sqrMagnitude = val2.get_sqrMagnitude();
                        if (!(sqrMagnitude > num))
                        {
                            result = uIKeyNavigation.get_gameObject();
                            num    = sqrMagnitude;
                        }
                    }
                }
            }
        }
        return(result);
    }
Esempio n. 3
0
    protected GameObject Get(Vector3 myDir, bool horizontal)
    {
        Transform t = transform;

        myDir = t.TransformDirection(myDir);
        Vector3    myCenter = GetCenter(gameObject);
        float      min      = float.MaxValue;
        GameObject go       = null;

        for (int i = 0; i < list.size; ++i)
        {
            UIKeyNavigation nav = list[i];
            if (nav == this)
            {
                continue;
            }

            // Ignore disabled buttons
            UIButton btn = nav.GetComponent <UIButton>();
            if (btn != null && !btn.isEnabled)
            {
                continue;
            }

            // Reject objects that are not within a 45 degree angle of the desired direction
            Vector3 dir = GetCenter(nav.gameObject) - myCenter;
            float   dot = Vector3.Dot(myDir, dir.normalized);
            if (dot < 0.707f)
            {
                continue;
            }

            // Exaggerate the movement in the undesired direction
            dir = t.InverseTransformDirection(dir);
            if (horizontal)
            {
                dir.y *= 2f;
            }
            else
            {
                dir.x *= 2f;
            }

            // Compare the distance
            float mag = dir.sqrMagnitude;
            if (mag > min)
            {
                continue;
            }
            go  = nav.gameObject;
            min = mag;
        }
        return(go);
    }
Esempio n. 4
0
    public GameObject Get(Vector3 myDir, float x = 1f, float y = 1f)
    {
        Transform t = transform;

        myDir = t.TransformDirection(myDir);
        Vector3    myCenter = GetCenter(gameObject);
        float      min      = float.MaxValue;
        GameObject go       = null;

        for (int i = 0; i < list.size; ++i)
        {
            UIKeyNavigation nav = list[i];
            if (nav == this || nav.constraint == Constraint.Explicit || !nav.isColliderEnabled)
            {
                continue;
            }

            // Ignore invisible widgets
            UIWidget widget = nav.GetComponent <UIWidget>();
            if (widget != null && widget.alpha == 0f)
            {
                continue;
            }

            // Reject objects that are not within a 45 degree angle of the desired direction
            Vector3 dir = GetCenter(nav.gameObject) - myCenter;
            float   dot = Vector3.Dot(myDir, dir.normalized);
            if (dot < 0.707f)
            {
                continue;
            }

            // Exaggerate the movement in the undesired direction
            dir    = t.InverseTransformDirection(dir);
            dir.x *= x;
            dir.y *= y;

            // Compare the distance
            float mag = dir.sqrMagnitude;
            if (mag > min)
            {
                continue;
            }
            go  = nav.gameObject;
            min = mag;
        }
        return(go);
    }
Esempio n. 5
0
    protected GameObject Get(Vector3 myDir, bool horizontal)
    {
        Transform transform = base.transform;

        myDir = transform.TransformDirection(myDir);
        Vector3    center = GetCenter(base.gameObject);
        float      num    = float.MaxValue;
        GameObject result = null;

        for (int i = 0; i < list.size; i++)
        {
            UIKeyNavigation uIKeyNavigation = list[i];
            if (uIKeyNavigation == this)
            {
                continue;
            }
            UIButton component = uIKeyNavigation.GetComponent <UIButton>();
            if (component != null && !component.isEnabled)
            {
                continue;
            }
            Vector3 direction = GetCenter(uIKeyNavigation.gameObject) - center;
            float   num2      = Vector3.Dot(myDir, direction.normalized);
            if (!(num2 < 0.707f))
            {
                direction = transform.InverseTransformDirection(direction);
                if (horizontal)
                {
                    direction.y *= 2f;
                }
                else
                {
                    direction.x *= 2f;
                }
                float sqrMagnitude = direction.sqrMagnitude;
                if (!(sqrMagnitude > num))
                {
                    result = uIKeyNavigation.gameObject;
                    num    = sqrMagnitude;
                }
            }
        }
        return(result);
    }
    protected GameObject Get(Vector3 myDir, bool horizontal)
    {
        Transform transform = base.get_transform();

        myDir = transform.TransformDirection(myDir);
        Vector3    center = UIKeyNavigation.GetCenter(base.get_gameObject());
        float      num    = 3.40282347E+38f;
        GameObject result = null;

        for (int i = 0; i < UIKeyNavigation.list.size; i++)
        {
            UIKeyNavigation uIKeyNavigation = UIKeyNavigation.list[i];
            if (!(uIKeyNavigation == this))
            {
                UIButton component = uIKeyNavigation.GetComponent <UIButton>();
                if (!(component != null) || component.isEnabled)
                {
                    Vector3 vector = UIKeyNavigation.GetCenter(uIKeyNavigation.get_gameObject()) - center;
                    float   num2   = Vector3.Dot(myDir, vector.get_normalized());
                    if (num2 >= 0.707f)
                    {
                        vector = transform.InverseTransformDirection(vector);
                        if (horizontal)
                        {
                            vector.y *= 2f;
                        }
                        else
                        {
                            vector.x *= 2f;
                        }
                        float sqrMagnitude = vector.get_sqrMagnitude();
                        if (sqrMagnitude <= num)
                        {
                            result = uIKeyNavigation.get_gameObject();
                            num    = sqrMagnitude;
                        }
                    }
                }
            }
        }
        return(result);
    }
Esempio n. 7
0
    public GameObject Get(Vector3 myDir, Single x = 1f, Single y = 1f)
    {
        Transform transform = base.transform;

        myDir = transform.TransformDirection(myDir);
        Vector3    center = UIKeyNavigation.GetCenter(base.gameObject);
        Single     num    = Single.MaxValue;
        GameObject result = (GameObject)null;

        for (Int32 i = 0; i < UIKeyNavigation.list.size; i++)
        {
            UIKeyNavigation uikeyNavigation = UIKeyNavigation.list[i];
            if (!(uikeyNavigation == this) && uikeyNavigation.constraint != UIKeyNavigation.Constraint.Explicit && uikeyNavigation.isColliderEnabled)
            {
                UIWidget component = uikeyNavigation.GetComponent <UIWidget>();
                if (!(component != (UnityEngine.Object)null) || component.alpha != 0f)
                {
                    Vector3 direction = UIKeyNavigation.GetCenter(uikeyNavigation.gameObject) - center;
                    Single  num2      = Vector3.Dot(myDir, direction.normalized);
                    if (num2 >= 0.707f)
                    {
                        direction    = transform.InverseTransformDirection(direction);
                        direction.x *= x;
                        direction.y *= y;
                        Single sqrMagnitude = direction.sqrMagnitude;
                        if (sqrMagnitude <= num)
                        {
                            result = uikeyNavigation.gameObject;
                            num    = sqrMagnitude;
                        }
                    }
                }
            }
        }
        return(result);
    }