示例#1
0
 /// <inheritdoc />
 protected override void HandleFrameChanged(int index)
 {
     _image.sprite = _sprites[index];
     if (_forceNativeSize)
     {
         _image.SetNativeSize();
     }
 }
示例#2
0
        void OnProduceImage()
        {
            GameObject imageGo = MyInstantiate(situated.imageGo);

            if (null == imageGo)
            {
                return;
            }

            Sprite sprite = LoadResource(layout.attr.image, typeof(UnityEngine.Sprite)) as Sprite;

            if (null == sprite)
            {
                return;
            }

            UnityEngine.UI.Image image = imageGo.GetComponent <UnityEngine.UI.Image>();
            image.SetNativeSize();
            image.sprite = sprite;
            image.name   = layout.attr.name;

            float width = layout.attr.width, height = layout.attr.height;

            if (height <= 0)
            {
                UnityEngine.UI.Text textParent = situated.mount.GetComponent <UnityEngine.UI.Text>();
                if (null != textParent)
                {
                    height = textParent.preferredHeight;
                    if (height <= 0)
                    {
                        height = sprite.rect.height;
                    }
                }
                else
                {
                    UnityEngine.UI.Image imageParent = situated.mount.GetComponent <UnityEngine.UI.Image>();
                    if (null != imageParent)
                    {
                        height = imageParent.rectTransform.sizeDelta.y;
                    }
                    else
                    {
                        Warning("an unusual mount parent is found, zero size is being used");
                    }
                }
                if (height <= 0)
                {
                    height = sprite.rect.height;
                }
            }
            if (width <= 0)
            {
                width = height / sprite.rect.height * sprite.rect.width;
            }

            MountTo(image.rectTransform, width, height);
        }
        private void ApplyTexture(Heightmap heightmap)
        {
            heightmap.Normalize();
            _texture = HeightmapConverter.ToTexture2D(heightmap);
            var rect = new Rect(0, 0, _texture.width, _texture.height);

            _image.sprite = Sprite.Create(_texture, rect, Vector2.one * 0.5f);
            _image.SetNativeSize();
        }
示例#4
0
        static StackObject *SetNativeSize_33(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

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

            instance_of_this_method.SetNativeSize();

            return(__ret);
        }
示例#5
0
        int UnityEngineUIImage_m_SetNativeSize(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;


            UnityEngine.UI.Image gen_to_be_invoked = (UnityEngine.UI.Image)translator.FastGetCSObj(L, 1);


            {
                gen_to_be_invoked.SetNativeSize(  );



                return(0);
            }
        }
        static int _m_SetNativeSize(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.UI.Image __cl_gen_to_be_invoked = (UnityEngine.UI.Image)translator.FastGetCSObj(L, 1);


            try {
                {
                    __cl_gen_to_be_invoked.SetNativeSize(  );



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
        void OnModelChange(CEventBaseArgs param)
        {
            WorshipModel owner = mOwner as WorshipModel;

            if (owner == null)
            {
                return;
            }

            // 头顶名字
            if (mTextComponent != null)
            {
                UnityEngine.Object.DestroyImmediate(mTextComponent);
            }
            mTextComponent = mOwner.GetModelParent().AddComponent <UI3DText>();
            UI3DText.StyleInfo styleInfo = new UI3DText.StyleInfo();
            float modelScale             = GameConstHelper.GetFloat("GAME_DUNGEON_WORSHIP_MODEL_SCALE");

            styleInfo.HeadOffset   = new Vector3(0f, mOwner.Height * modelScale, 0f);
            styleInfo.ScreenOffset = UI3DText.NameTextScreenOffset * modelScale;
            mTextComponent.SetHeadTrans(mOwner.GetModelParent().transform);
            mTextComponent.ResetStyleInfo(styleInfo);
            string text = "<color=#ffc319>" + owner.Rank.ToString();

            if (owner.Rank == 1)
            {
                text = text + DBConstText.GetText("ANSWER_WORSHIP_1"); // "st雕像";
            }
            else if (owner.Rank == 2)
            {
                text = text + DBConstText.GetText("ANSWER_WORSHIP_2");  //"nd雕像";
            }
            else if (owner.Rank == 3)
            {
                text = text + DBConstText.GetText("ANSWER_WORSHIP_3");  //"rd雕像";
            }
            else
            {
                text = text + DBConstText.GetText("ANSWER_WORSHIP_4");  //"th雕像";
            }
            text = text + "</color>";
            mTextComponent.RankTextLabel = text;
            mTextComponent.FontSize      = 22;
            if (string.IsNullOrEmpty(owner.GuildName) == false)
            {
                mTextComponent.GuildNameTextLabel = "<color=#4ef269><" + owner.GuildName + "></color>";
            }
            mTextComponent.Text = "<color=#5ec4ff>" + owner.UserName + "</color>";

            // 膜拜按钮
            if (mWorshipButtonComponent != null)
            {
                UnityEngine.Object.DestroyImmediate(mWorshipButtonComponent);
            }
            mWorshipButtonComponent = mOwner.GetModelParent().AddComponent <UI3DText>();
            styleInfo              = new UI3DText.StyleInfo();
            modelScale             = GameConstHelper.GetFloat("GAME_DUNGEON_WORSHIP_MODEL_SCALE");
            styleInfo.HeadOffset   = Vector3.zero;
            styleInfo.ScreenOffset = Vector3.zero;
            mWorshipButtonComponent.SetHeadTrans(ModelHelper.FindChildInHierarchy(mOwner.GetModelParent().transform, "root_node"));
            mWorshipButtonComponent.ResetStyleInfo(styleInfo);
            mWorshipButtonComponent.SetButtonStyle("MainWindow_New@Chatting@Praisebtn", DBConstText.GetText("WORSHIP"), 24, new Color(0.2f, 0.2f, 0.2f), new Vector3(0f, -9f, 0f));
            UnityEngine.UI.Image buttonImage = mWorshipButtonComponent.ButtonImage;
            if (buttonImage != null)
            {
                buttonImage.sprite = mWorshipButtonComponent.LoadSprite("MainWindow_New@Chatting@Hands");
                buttonImage.SetNativeSize();
                buttonImage.transform.localPosition = new Vector3(75, 40, 0);
                xc.ui.ugui.TweenPosition tween = xc.ui.ugui.TweenPosition.Begin(buttonImage.gameObject, 0.8f, new Vector3(100, 55, 0));
                tween.style = ui.ugui.UITweener.Style.PingPong;
                buttonImage.gameObject.SetActive(false);
            }
            mWorshipButtonComponent.SetClickCallback(() =>
            {
                mWorshipButtonComponent.ShowButton(false);
                if (buttonImage != null)
                {
                    buttonImage.gameObject.SetActive(false);
                }

                var data  = new C2SPlayerWorship();
                data.rank = owner.Rank;
                NetClient.GetBaseClient().SendData <C2SPlayerWorship>(NetMsg.MSG_PLAYER_WORSHIP, data);

                Actor localPlayer = Game.Instance.GetLocalPlayer();
                if (localPlayer != null)
                {
                    localPlayer.AttackCtrl.Attack(GameConstHelper.GetUint("GAME_DUNGEON_WORSHIP_SKILL_ID"));
                }
            });
            mWorshipButtonComponent.ShowButton(false);

            mTextComponent.Honor = mOwner.Honor;
            mTextComponent.Title = mOwner.Title;
        }