예제 #1
0
 static public int AdjustByDPI_s(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
         System.Single a1;
         checkType(l, 1, out a1);
         var ret = NGUIMath.AdjustByDPI(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     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
 }
예제 #2
0
        int activeHeight(Vector2 screen)
        {
            if (Scaling == UIRoot.Scaling.Flexible)
            {
                float aspect = screen.x / screen.y;

                if (screen.y < MinimumHeight)
                {
                    screen.y = MinimumHeight;
                    screen.x = screen.y * aspect;
                }
                else if (screen.y > MaximumHeight)
                {
                    screen.y = MaximumHeight;
                    screen.x = screen.y * aspect;
                }

                // Portrait mode uses the maximum of width or height to shrink the UI
                int height = Mathf.RoundToInt((ShrinkPortraitUI && screen.y > screen.x) ? screen.y / aspect : screen.y);

                // Adjust the final value by the DPI setting
                return(AdjustByDPI ? NGUIMath.AdjustByDPI(height) : height);
            }
            else
            {
                var cons = constraint;
                if (cons == UIRoot.Constraint.FitHeight)
                {
                    return(ManualHeight);
                }

                float aspect        = screen.x / screen.y;
                float initialAspect = (float)ManualWidth / ManualHeight;

                switch (cons)
                {
                case UIRoot.Constraint.FitWidth:
                {
                    return(Mathf.RoundToInt(ManualWidth / aspect));
                }

                case UIRoot.Constraint.Fit:
                {
                    return((initialAspect > aspect) ? Mathf.RoundToInt(ManualWidth / aspect) : ManualHeight);
                }

                case UIRoot.Constraint.Fill:
                {
                    return((initialAspect < aspect) ? Mathf.RoundToInt(ManualWidth / aspect) : ManualHeight);
                }
                }
                return(ManualHeight);
            }
        }
예제 #3
0
 static public int AdjustByDPI_s(IntPtr l)
 {
     try {
         System.Single a1;
         checkType(l, 1, out a1);
         var ret = NGUIMath.AdjustByDPI(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
예제 #4
0
 static public int AdjustByDPI_s(IntPtr l)
 {
     try {
         System.Single a1;
         checkType(l, 1, out a1);
         var ret = NGUIMath.AdjustByDPI(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #5
0
 public unsafe static long $Invoke0(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(NGUIMath.AdjustByDPI(*(float *)args)));
 }