Пример #1
0
    static int SetLookAtParam(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 8 && LuaScriptMgr.CheckTypes(L, 1, typeof(GImageModel), typeof(float), typeof(float), typeof(float), typeof(float), typeof(float), typeof(float), typeof(float)))
        {
            GImageModel obj  = (GImageModel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GImageModel");
            float       arg0 = (float)LuaScriptMgr.GetNumber(L, 2);
            float       arg1 = (float)LuaScriptMgr.GetNumber(L, 3);
            float       arg2 = (float)LuaScriptMgr.GetNumber(L, 4);
            float       arg3 = (float)LuaScriptMgr.GetNumber(L, 5);
            float       arg4 = (float)LuaScriptMgr.GetNumber(L, 6);
            float       arg5 = (float)LuaScriptMgr.GetNumber(L, 7);
            float       arg6 = (float)LuaScriptMgr.GetNumber(L, 8);
            obj.SetCameraSize(arg0);
            obj.SetLookAtPos(arg1, arg2, arg3);
            obj.SetLookAtRot(arg4, arg5, arg6);
        }
        //else if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(GImageModel), typeof(float), typeof(float)))
        //{
        //    GImageModel obj = (GImageModel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GImageModel");
        //    float arg0 = (float)LuaScriptMgr.GetNumber(L, 2);
        //    float arg1 = (float)LuaScriptMgr.GetNumber(L, 3);
        //    obj.SetLookAtParam(arg0, arg1);
        //}
        else
        {
            Common.HobaDebuger.LogError("SetLookAtParam param count != 8");
        }

        return(0);
    }
Пример #2
0
    public static Rect FitUV(GImageModel g, FIT_MODE fit)
    {
        Rect rect = g.rectTransform.rect;
        Rect rv   = new Rect(0, 0, 1, 1);

        if (fit == FIT_MODE.Height && rect.width != 0)
        {
            float inv_asp = (float)rect.height / (float)rect.width;
            rv.width = inv_asp;
            rv.x     = (1 - inv_asp) * 0.5f;
        }

        if (fit == FIT_MODE.Width && rect.height != 0)
        {
            float inv_asp = (float)rect.width / (float)rect.height;
            rv.height = inv_asp;
            rv.y      = (1 - inv_asp) * 0.5f;
        }

        if (g.FlipX)
        {
            rv.width = -rv.width;
            rv.x     = 1 - rv.x;
        }

        return(rv);
    }
Пример #3
0
    static int SetModel(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        GImageModel obj  = (GImageModel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GImageModel");
        GameObject  arg0 = (GameObject)LuaScriptMgr.GetUnityObject(L, 2, typeof(GameObject));

        obj.SetModel(arg0);
        return(0);
    }
Пример #4
0
    static int UnLoadModel(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        GImageModel obj = (GImageModel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GImageModel");

        obj.UnLoadModel();

        return(0);
    }
Пример #5
0
    public void FitGraph()
    {
        this.uvRect = GImageModel.FitSize(this, FitMode);

        if (this.material != null && this.material.HasProperty(ShaderIDs.UIAlphaTex))
        {
            Rect rv = GImageModel.FitUV(this, FitMode);
            this.material.SetTextureOffset(ShaderIDs.UIAlphaTex, new Vector2(FlipMaskX ? 1 - rv.x : rv.x, rv.y));
            this.material.SetTextureScale(ShaderIDs.UIAlphaTex, new Vector2(FlipMaskX ? -rv.width : rv.width, rv.height));
        }
    }
Пример #6
0
    static int SetCameraFarClip(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GImageModel), typeof(float)))
        {
            GImageModel obj  = (GImageModel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GImageModel");
            float       arg0 = (float)LuaScriptMgr.GetNumber(L, 2);
            obj.SetCameraFarClip(arg0);
        }
        return(0);
    }
Пример #7
0
    static int SetCameraType(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GImageModel), typeof(bool)))
        {
            GImageModel obj  = (GImageModel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GImageModel");
            bool        arg0 = (bool)LuaScriptMgr.GetBoolean(L, 2);
            obj.SetCameraType(arg0);
        }
        return(0);
    }
Пример #8
0
    static int AlignSystemWithModelForward(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GImageModel), typeof(Vector3)))
        {
            GImageModel obj = (GImageModel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GImageModel");
            //Vector3 arg0 = (Vector3)LuaScriptMgr.GetNumber(L, 2);
            Vector3 arg0 = LuaScriptMgr.GetVector3(L, 2);
            obj.AlignSystemWithModelForward(arg0);
        }
        return(0);
    }
Пример #9
0
    static int SetGroundOffset(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(GImageModel), typeof(float), typeof(float)))
        {
            GImageModel obj  = (GImageModel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GImageModel");
            float       arg0 = (float)LuaScriptMgr.GetNumber(L, 2);
            float       arg1 = (float)LuaScriptMgr.GetNumber(L, 3);
            obj.SetGroundOffset(arg0, arg1);
        }
        return(0);
    }
Пример #10
0
    static int SetColor(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(GImageModel), typeof(float), typeof(float), typeof(float)))
        {
            GImageModel obj  = (GImageModel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "SetColor");
            float       arg0 = (float)LuaScriptMgr.GetNumber(L, 2);
            float       arg1 = (float)LuaScriptMgr.GetNumber(L, 3);
            float       arg2 = (float)LuaScriptMgr.GetNumber(L, 4);
            obj.SetColor(arg0, arg1, arg2);
        }
        else
        {
            Common.HobaDebuger.LogError("SetColor param count != 4");
        }
        return(0);
    }
Пример #11
0
    //This overrides the callback of a UI Component to a single call
    public void RegisterSingleObjHandler(GameObject control, int class_type, bool recursion)
    {
        if (control == null)
        {
            Debug.LogError("Cannot register event since the control object is null!");
            return;
        }

        System.Type type = WrapClassID.GetClassType(class_type);

        if (type == typeof(UnityEngine.UI.Button) || type == typeof(GButton))
        {
            GButton gbtn = control.GetComponent <GButton>();
            if (gbtn != null)
            {
                gbtn.OnClick = OnClick;
                return;
            }

            Button btn = control.GetComponent <Button>();
            if (btn != null)
            {
                btn.onClick.RemoveAllListeners();
                btn.onClick.AddListener(delegate() { OnClick(btn.gameObject); });
            }
            if (recursion)
            {
                GButton[] btns = control.GetComponentsInChildren <GButton>(true);
                for (int i = 0; i < btns.Length; i++)
                {
                    if (btns[i] != null)
                    {
                        btns[i].OnClick = OnClick;
                    }
                }
            }
        }
        else if (type == typeof(Toggle))
        {
            if (recursion)
            {
                Toggle[] toggles = control.GetComponentsInChildren <Toggle>(true);
                for (int i = 0; i < toggles.Length; i++)
                {
                    if (toggles[i] != null)
                    {
                        toggles[i].onValueChanged.RemoveAllListeners();
                        GameObject go = toggles[i].gameObject;
                        toggles[i].onValueChanged.AddListener(delegate(bool ischeck) { OnToggle(go, ischeck); });
                    }
                }
            }
            else
            {
                Toggle toggle = control.GetComponent <Toggle>();
                if (toggle != null)
                {
                    toggle.onValueChanged.RemoveAllListeners();
                    toggle.onValueChanged.AddListener(delegate(bool ischeck) { OnToggle(toggle.gameObject, ischeck); });
                }
            }
        }
        else if (type == typeof(GNewIOSToggle))
        {
            GNewIOSToggle gTgl = control.GetComponent <GNewIOSToggle>();
            if (gTgl != null)
            {
                gTgl.OnClick = OnClick;
                //gTgl.OnValueChanged = OnToggleSpecial;
            }
            if (recursion)
            {
                GNewIOSToggle[] gToggles = control.GetComponentsInChildren <GNewIOSToggle>(true);
                for (int i = 0; i < gToggles.Length; i++)
                {
                    if (gToggles[i] != null)
                    {
                        gToggles[i].OnClick = OnClick;
                        //gToggles[i].OnValueChanged = OnToggleSpecial;
                    }
                }
            }
        }
        else if (type == typeof(GText))
        {
            // 现在需求中GText不在root上,所以这么处理;其实不太好
            GText gtext = control.GetComponentInChildren <GText>();
            if (gtext != null)
            {
                gtext.OnClick = OnGTextClick;
            }
            if (recursion)
            {
                GText[] gts = control.GetComponentsInChildren <GText>(true);
                for (int i = 0; i < gts.Length; i++)
                {
                    if (gts[i] != null)
                    {
                        gts[i].OnClick = OnGTextClick;
                    }
                }
            }
        }
        else if (type == typeof(GImageModel))
        {
            GImageModel gim = control.GetComponent <GImageModel>();
            if (gim != null)
            {
                gim.OnModelClick = OnClick;
            }
            if (recursion)
            {
                GImageModel[] gims = control.GetComponentsInChildren <GImageModel>(true);
                for (int i = 0; i < gims.Length; i++)
                {
                    if (gims[i] != null)
                    {
                        gims[i].OnModelClick = OnClick;
                    }
                }
            }
        }
        else if (type == typeof(Slider))
        {
            Slider sld = control.GetComponent <Slider>();
            if (sld != null)
            {
                sld.onValueChanged.AddListener(delegate(float value) { OnSliderChanged(sld.gameObject, value); });
            }
            if (recursion)
            {
                Slider[] sliders = control.GetComponentsInChildren <Slider>(true);
                for (int i = 0; i < sliders.Length; i++)
                {
                    if (sliders[i] != null)
                    {
                        sliders[i].onValueChanged.AddListener(delegate(float value) { OnSliderChanged(sliders[i].gameObject, value); });
                    }
                }
            }
        }
        else if (type == typeof(GScaleScroll))
        {
            GScaleScroll gss = control.GetComponent <GScaleScroll>();
            if (gss != null)
            {
                gss.onScaleChanged = OnScaleChanged;
            }
            if (recursion)
            {
                GScaleScroll[] gsss = control.GetComponentsInChildren <GScaleScroll>(true);
                for (int i = 0; i < gsss.Length; i++)
                {
                    if (gsss[i] != null)
                    {
                        gsss[i].onScaleChanged = OnScaleChanged;
                    }
                }
            }
        }
        else if (type == typeof(GBlood))
        {
            GBlood gwv = control.GetComponent <GBlood>();
            if (gwv != null)
            {
                gwv.OnTweenFinishCallBack = this.OnDOTComplete;
            }
            if (recursion)
            {
                GBlood[] gwvs = control.GetComponentsInChildren <GBlood>(true);
                for (int i = 0; i < gwvs.Length; i++)
                {
                    gwvs[i].OnTweenFinishCallBack = this.OnDOTComplete;
                }
            }
        }
        else if (type == typeof(GWebView))
        {
            GWebView gwv = control.GetComponent <GWebView>();
            if (gwv != null)
            {
                gwv.OnReceiveMessage = this.OnReceiveWebViewMessage;
            }
            if (recursion)
            {
                GWebView[] gwvs = control.GetComponentsInChildren <GWebView>(true);
                for (int i = 0; i < gwvs.Length; i++)
                {
                    gwvs[i].OnReceiveMessage = OnReceiveWebViewMessage;
                }
            }
        }
        else if (type == typeof(GNewListBase))
        {
            GNewListBase list = control.GetComponent <GNewListBase>();
            if (list != null)
            {
                list.ClickItemCallBack = this.OnSelectItem;
                //list.PressItemCallBack = this.OnPressItem;
                //list.ReleaseItemCallBack = this.OnReleaseItem;
                list.LongPressCallBack = this.OnLongPressItem;
                list.InitItemCallBack  = this.OnInitItem;

                if (list.HasChildButton)
                {
                    list.ClickItemButtonCallBack = this.OnSelectItemButton;
                }
            }
            if (recursion)
            {
                GNewListBase[] lists = control.GetComponentsInChildren <GNewListBase>(true);
                for (int i = 0; i < lists.Length; i++)
                {
                    lists[i].ClickItemCallBack = this.OnSelectItem;
                    lists[i].LongPressCallBack = this.OnLongPressItem;
                    lists[i].InitItemCallBack  = this.OnInitItem;
                    if (lists[i].HasChildButton)
                    {
                        lists[i].ClickItemButtonCallBack = this.OnSelectItemButton;
                    }
                }
            }
        }
        else
        {
            // TODO: 将来根据需要自行扩展
            HobaDebuger.LogError("<RegisterUIEventHandler>WrapClassID not supported!" + class_type);
        }
    }