Example #1
0
    static int get_verticalFit(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.ContentSizeFitter         obj = (UnityEngine.UI.ContentSizeFitter)o;
            UnityEngine.UI.ContentSizeFitter.FitMode ret = obj.verticalFit;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index verticalFit on a nil value" : e.Message));
        }
    }
    static int set_verticalFit(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.ContentSizeFitter         obj  = (UnityEngine.UI.ContentSizeFitter)o;
            UnityEngine.UI.ContentSizeFitter.FitMode arg0 = (UnityEngine.UI.ContentSizeFitter.FitMode)ToLua.CheckObject(L, 2, typeof(UnityEngine.UI.ContentSizeFitter.FitMode));
            obj.verticalFit = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index verticalFit on a nil value"));
        }
    }
        static StackObject *set_verticalFit_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.UI.ContentSizeFitter.FitMode @value = (UnityEngine.UI.ContentSizeFitter.FitMode) typeof(UnityEngine.UI.ContentSizeFitter.FitMode).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.UI.ContentSizeFitter instance_of_this_method = (UnityEngine.UI.ContentSizeFitter) typeof(UnityEngine.UI.ContentSizeFitter).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.verticalFit = value;

            return(__ret);
        }
Example #4
0
 /// <summary>
 /// Adds an auto-fit resizer to a UI element.
 ///
 /// UI elements should be active before any layouts are added, especially if they are
 /// to be frozen.
 /// </summary>
 /// <param name="uiElement">The element to resize.</param>
 /// <param name="dynamic">true to use the Unity content size fitter which adjusts to
 /// content changes, or false to set the size only once.</param>
 /// <param name="modeHoriz">The sizing mode to use in the horizontal direction.</param>
 /// <param name="modeVert">The sizing mode to use in the vertical direction.</param>
 /// <returns>The UI element, for call chaining.</returns>
 public static GameObject AddSizeFitter(GameObject uiElement, bool dynamic = false,
                                        ContentFitMode modeHoriz           = ContentFitMode.PreferredSize,
                                        ContentFitMode modeVert            = ContentFitMode.PreferredSize)
 {
     if (uiElement == null)
     {
         throw new ArgumentNullException(nameof(uiElement));
     }
     if (dynamic)
     {
         var fitter = uiElement.AddOrGet <ContentSizeFitter>();
         fitter.horizontalFit = modeHoriz;
         fitter.verticalFit   = modeVert;
         fitter.enabled       = true;
     }
     else
     {
         FitSizeNow(uiElement, modeHoriz, modeVert);
     }
     return(uiElement);
 }
Example #5
0
 public static void ContentSizeFitter(ContentSizeFitter csf, UnityEngine.UI.ContentSizeFitter.FitMode h, UnityEngine.UI.ContentSizeFitter.FitMode v)
 {
     csf.horizontalFit = h;
     csf.verticalFit   = v;
 }
    static int QPYX_IntToEnum_YXQP(IntPtr L_YXQP)
    {
        int QPYX_arg0_YXQP = (int)LuaDLL.lua_tonumber(L_YXQP, 1);               UnityEngine.UI.ContentSizeFitter.FitMode QPYX_o_YXQP = (UnityEngine.UI.ContentSizeFitter.FitMode)QPYX_arg0_YXQP;

        ToLua.Push(L_YXQP, QPYX_o_YXQP);                return(1);
    }
 static void QPYX_Push_YXQP(IntPtr L_YXQP, UnityEngine.UI.ContentSizeFitter.FitMode arg_YXQP)
 {
     ToLua.Push(L_YXQP, arg_YXQP);
 }
Example #8
0
        /// <summary>
        /// Fits the UI element's size immediately, as if ContentSizeFitter was created on it,
        /// but does not create a component and only affects the size once.
        /// </summary>
        /// <param name="uiElement">The element to resize.</param>
        /// <param name="modeHoriz">The sizing mode to use in the horizontal direction.</param>
        /// <param name="modeVert">The sizing mode to use in the vertical direction.</param>
        /// <returns>The UI element, for call chaining.</returns>
        private static void FitSizeNow(GameObject uiElement, ContentFitMode modeHoriz,
                                       ContentFitMode modeVert)
        {
            float width = 0.0f, height = 0.0f;

            if (uiElement == null)
            {
                throw new ArgumentNullException(nameof(uiElement));
            }
            // Follow order in https://docs.unity3d.com/Manual/UIAutoLayout.html
            var elements    = uiElement.GetComponents <ILayoutElement>();
            var constraints = uiElement.AddOrGet <LayoutElement>();
            var rt          = uiElement.AddOrGet <RectTransform>();

            // Calculate horizontal
            foreach (var layoutElement in elements)
            {
                layoutElement.CalculateLayoutInputHorizontal();
            }
            if (modeHoriz != ContentFitMode.Unconstrained)
            {
                // Layout horizontal
                foreach (var layoutElement in elements)
                {
                    switch (modeHoriz)
                    {
                    case ContentFitMode.MinSize:
                        width = Math.Max(width, layoutElement.minWidth);
                        break;

                    case ContentFitMode.PreferredSize:
                        width = Math.Max(width, layoutElement.preferredWidth);
                        break;

                    default:
                        break;
                    }
                }
                width = Math.Max(width, constraints.minWidth);
                rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
                constraints.minWidth      = width;
                constraints.flexibleWidth = 0.0f;
            }
            // Calculate vertical
            foreach (var layoutElement in elements)
            {
                layoutElement.CalculateLayoutInputVertical();
            }
            if (modeVert != ContentFitMode.Unconstrained)
            {
                // Layout vertical
                foreach (var layoutElement in elements)
                {
                    switch (modeVert)
                    {
                    case ContentFitMode.MinSize:
                        height = Math.Max(height, layoutElement.minHeight);
                        break;

                    case ContentFitMode.PreferredSize:
                        height = Math.Max(height, layoutElement.preferredHeight);
                        break;

                    default:
                        break;
                    }
                }
                height = Math.Max(height, constraints.minHeight);
                rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);
                constraints.minHeight      = height;
                constraints.flexibleHeight = 0.0f;
            }
        }
Example #9
0
 static void Push(IntPtr L, UnityEngine.UI.ContentSizeFitter.FitMode arg)
 {
     ToLua.Push(L, arg);
 }