示例#1
0
 private void AddEvent(string v)
 {
     if (!string.IsNullOrEmpty(v))
     {
         string[] fieldEvents = v.Split(FreeMessageConstant.SpliterRecord);
         foreach (string fieldEvent in fieldEvents)
         {
             string[] vs = fieldEvent.Split(FreeMessageConstant.SpilterField);
             if (vs.Length == 3)
             {
                 GameObject obj = UnityUiUtility.FindUIObject(currentObject, vs[0].Trim());
                 if (obj != null)
                 {
                     Graphic gra = obj.GetComponent <Graphic>();
                     if (gra != null)
                     {
                         if (gra is RawImage || gra is Image || gra is Text)
                         {
                             ItemComponent item = obj.AddComponent <ItemComponent>();
                             item.EventKey = vs[1].Trim();
                             AddEvent(obj, int.Parse(vs[2].Trim()));
                         }
                     }
                 }
             }
         }
     }
 }
示例#2
0
        public object Frame(int frameTime)
        {
            if (parentGround == null)
            {
                parentGround = UnityUiUtility.FindUIObject(GroundParentPath);
            }

            if (parentBag == null)
            {
                parentBag = UnityUiUtility.FindUIObject(BagParentPath);
            }

            InitialBag();

            SimpleFreeUI bag = SingletonManager.Get <FreeUiManager>().GetUi("bagSystemUI");

            if (bag.Visible != isOpen)
            {
                if (!bag.Visible)
                {
                    SingletonManager.Get <FreeUiManager>().Contexts1.ui.uI.IsShowCrossHair = true;
                    SingletonManager.Get <FreeUiManager>().Contexts1.userInput.userInputManager.Helper.UnblockKey(bagBlockKeyId);
                    SingletonManager.Get <FreeUiManager>().Contexts1.userInput.userInputManager.Helper.UnblockPointer(bagBlockPointerId);
                }
                else
                {
                    SingletonManager.Get <FreeUiManager>().Contexts1.ui.uI.IsShowCrossHair = false;
                    bagBlockKeyId     = SingletonManager.Get <FreeUiManager>().Contexts1.userInput.userInputManager.Helper.BlockKey(UserInputManager.Lib.Layer.Ui);
                    bagBlockPointerId = SingletonManager.Get <FreeUiManager>().Contexts1.userInput.userInputManager.Helper.BlockPointer(UserInputManager.Lib.Layer.Ui);
                }
                isOpen = bag.Visible;

                if (CursorLocker.SystemUnlock)
                {
                    //Unlock
                    SingletonManager.Get <FreeUiManager>().Contexts1.ui.uI.IsShowCrossHair = false;
                    CursorLocker.SystemBlockKeyId     = SingletonManager.Get <FreeUiManager>().Contexts1.userInput.userInputManager.Helper.BlockKey(UserInputManager.Lib.Layer.System);
                    CursorLocker.SystemBlockPointerId = SingletonManager.Get <FreeUiManager>().Contexts1.userInput.userInputManager.Helper.BlockPointer(UserInputManager.Lib.Layer.System);
                }
            }

            if (bag.Visible)
            {
                FreePrefabLoader.CacheGameObject(new AssetInfo("ui/client/prefab/chicken", "ItemBar"), 50);
                FreePrefabLoader.CacheGameObject(new AssetInfo("ui/client/prefab/chicken", "CaseNameBar"), 5);

                if (parentGround != null && parentBag != null && DateTime.Now.Ticks - lastUpdateTime > 10000)
                {
                    lastUpdateTime = DateTime.Now.Ticks;

                    Contexts context = SingletonManager.Get <FreeUiManager>().Contexts1;

                    PlayerEntity player = context.player.flagSelfEntity;

                    RefreshGround(context, player);
                    RefreshBag(context, player);
                }
            }
            return(null);
        }
示例#3
0
        public void Handle(SimpleProto data)
        {
            Contexts contexts = SingletonManager.Get <FreeUiManager>().Contexts1;
            string   uiKey    = data.Ss[0];

            GameObject obj = UnityUiUtility.FindUIObject(uiKey);

            if (obj != null)
            {
                Image[] imgs = obj.GetComponentsInChildren <Image>();
                foreach (Image img in imgs)
                {
                }
            }
        }
示例#4
0
        private void ReturnObject(ItemBar bar)
        {
            FreePrefabComponent prefab = bar.prefab;
            GameObject          obj    = (GameObject)prefab.currentObject;

            if (obj != null)
            {
                obj.GetComponent <Transform>().parent = null;
                FreePrefabLoader.ReturnGameObject(obj, prefab.assetInfo);

                string   imgUrl      = "";
                string[] fieldValues = bar.value.Split(FreeMessageConstant.SpliterRecord);

                foreach (string fieldValue in fieldValues)
                {
                    string[] vs = fieldValue.Split(FreeMessageConstant.SpilterField);
                    if (vs.Length == 2)
                    {
                        if (vs[0].Trim() == "IMG_WeaponIcon")
                        {
                            imgUrl = vs[1].Trim();
                        }
                    }
                }

                GameObject img = UnityUiUtility.FindUIObject(obj, "IMG_WeaponIcon");
                if (img != null && !string.IsNullOrEmpty(imgUrl))
                {
                    int       last       = imgUrl.Trim().LastIndexOf("/");
                    string    buddleName = imgUrl.Trim().Substring(0, last);
                    string    assetName  = imgUrl.Trim().Substring(last + 1);
                    AssetInfo info       = new AssetInfo(buddleName, assetName);

                    Graphic gra = img.GetComponent <Graphic>();
                    if (gra is Image)
                    {
                        FreeUILoader.ReturnGameObject(((Image)gra).sprite, info);
                    }
                    if (gra is RawImage)
                    {
                        FreeUILoader.ReturnGameObject(((RawImage)gra).texture, info);
                    }
                }
            }
        }
示例#5
0
        private void SetOneValue(string[] vs)
        {
            GameObject obj = UnityUiUtility.FindUIObject(currentObject, vs[0].Trim());

            if (obj != null)
            {
                Graphic gra = obj.GetComponent <Graphic>();
                if (gra != null)
                {
                    if (gra is Text)
                    {
                        ((Text)gra).text = vs[1].Trim();
                    }

                    if (gra is RawImage || gra is Image)
                    {
                        if (string.IsNullOrEmpty(vs[1]))
                        {
                            if (gra is RawImage)
                            {
                                ((RawImage)gra).texture = ResourceUtility.GetTransparentTexture();
                            }
                            if (gra is Image)
                            {
                                Texture2D tex = ResourceUtility.GetTransparentTexture();
                                ((Image)gra).sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero);
                            }
                        }
                        else
                        {
                            int    last       = vs[1].Trim().LastIndexOf("/");
                            string buddleName = vs[1].Trim().Substring(0, last);
                            string assetName  = vs[1].Trim().Substring(last + 1);
                            FreeUILoader.Load(gra, buddleName, assetName);
                        }
                    }
                }
            }
        }
示例#6
0
        private void SetWeight()
        {
            GameObject weight = UnityUiUtility.FindUIObject("SelfitemPanel/TEXT_Weight");

            if (weight != null)
            {
                Text text = weight.GetComponent <Text>();
                if (text != null)
                {
                    text.text = CurrentBag.Ks[2] + "/" + CurrentBag.Ks[1];
                }
            }

            weight = UnityUiUtility.FindUIObject("GrounditemPanel/TEXT_CaseName");
            if (weight != null)
            {
                Text text = weight.GetComponent <Text>();
                if (text != null)
                {
                    text.text = "";
                }
            }
        }
示例#7
0
        private void OnBeginCloneDelegate(PointerEventData eventData)
        {
            if (dragObj == null)
            {
                dragObj = new GameObject();
                RectTransform t = dragObj.AddComponent <RectTransform>();
                dragObj.AddComponent <ItemComponent>();
                dragObj.AddComponent <Image>();
            }

            ItemComponent item = dragObj.GetComponent <ItemComponent>();

            item.EventKey = eventData.pointerDrag.GetComponent <ItemComponent>().EventKey;
            Image pointerImg = eventData.pointerDrag.GetComponent <Image>();

            Texture2D tex = null;

            if (pointerImg != null)
            {
                tex = (Texture2D)pointerImg.mainTexture;
            }

            GameObject clone = UnityUiUtility.FindUIObject(this.currentObject, "IMG_WeaponIcon");

            if (clone != null && this.name == "bag/ItemBar")
            {
                tex = (Texture2D)clone.GetComponent <Image>().mainTexture;
            }
            Image img = dragObj.GetComponent <Image>();

            img.sprite        = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero);
            img.raycastTarget = false;

            dragObj.transform.position = eventData.position;
            dragObj.transform.parent   = UnityUiUtility.RootCanvas.transform;
        }
 private static GameObject GetGameObject(int key, string part)
 {
     return(UnityUiUtility.FindUIObject("WeaponSlot" + key + "/VISIBLE_WeaponPartSlot" + part));
 }