UnityEngine.RectTransform.GetLocalCorners C# (CSharp) Method

GetLocalCorners() public method

Get the corners of the calculated rectangle in the local space of its Transform.

public GetLocalCorners ( Vector3 fourCornersArray ) : void
fourCornersArray Vector3 Array that corners should be filled into.
return void
        public void GetLocalCorners(Vector3[] fourCornersArray)
        {
            if ((fourCornersArray == null) || (fourCornersArray.Length < 4))
            {
                Debug.LogError("Calling GetLocalCorners with an array that is null or has less than 4 elements.");
            }
            else
            {
                Rect rect = this.rect;
                float x = rect.x;
                float y = rect.y;
                float xMax = rect.xMax;
                float yMax = rect.yMax;
                fourCornersArray[0] = new Vector3(x, y, 0f);
                fourCornersArray[1] = new Vector3(x, yMax, 0f);
                fourCornersArray[2] = new Vector3(xMax, yMax, 0f);
                fourCornersArray[3] = new Vector3(xMax, y, 0f);
            }
        }

Usage Example

コード例 #1
0
 static public int GetLocalCorners(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.RectTransform self = (UnityEngine.RectTransform)checkSelf(l);
         UnityEngine.Vector3[]     a1;
         checkArray(l, 2, out a1);
         self.GetLocalCorners(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
All Usage Examples Of UnityEngine.RectTransform::GetLocalCorners