示例#1
0
        private void OnEnable()
        {
            backpack = serializedObject.targetObject as KGUI_Backpack;

            content         = serializedObject.FindProperty("content");
            backpackItem    = serializedObject.FindProperty("backpackItem");
            areaPanel       = serializedObject.FindProperty("areaPanel");
            backpackTrigger = serializedObject.FindProperty("backpackTrigger");

            backpackIcons = serializedObject.FindProperty("backpackIcons");
        }
        public void OnInitialized(KGUI_Backpack backpack, KGUI_Backpack_ItemData config)
        {
            dataConfig = config;
            Backpack   = backpack;

            txtName   = transform.Find("Name").GetComponent <Text>();
            txtNumber = transform.Find("Number").GetComponent <Text>();
            Icon      = transform.Find("Icon").GetComponent <Image>();

            ////设置初始值
            //buttonType = ButtonType.Image;
            //image = GetComponent<Image>();

            //normalSprite = Backpack.dataConfig.normalIcon;
            //enterSprite = Backpack.dataConfig.enterIcon;
            //disableSprite = Backpack.dataConfig.disableIcon;

            //获取到路径信息
            //normalIcon = config.NormalSprite;
            //disableIcon = config.DisableSprite;

            normalIcon  = backpack.backpackIcons.GetSprite(config.normalSpritePath);
            disableIcon = backpack.backpackIcons.GetSprite(config.disableSpritePath);

            //disableIcon = config.DisableSprite;

            Icon.sprite = normalIcon;

            txtName.text = config.Name;

            if (txtNumber != null)
            {
                txtNumber.text = config.number.ToString();
            }

            _equipmentNumber = config.number;
            _equipmentName   = config.Name;

            GenerateItems = new List <GameObject>();

            //刷新
            RefreshShow();
        }
示例#3
0
        public void OnInitialized(KGUI_Backpack backpack, KGUI_Backpack_ItemData config)
        {
            dataConfig = config;
            Backpack   = backpack;

            txtName   = transform.Find("Name").GetComponent <Text>();
            txtNumber = transform.Find("Number").GetComponent <Text>();
            Icon      = transform.Find("Icon").GetComponent <Image>();

            Sprite[] Icons = new Sprite[backpack.backpackIcons.spriteCount];
            backpack.backpackIcons.GetSprites(Icons);
            //normalIcon = Icons.ToList().Find(obj => obj.name.Equals(config.normalSpritePath.Trim()));
            //disableIcon = Icons.ToList().Find(obj => obj.name.Equals(config.disableSpritePath.Trim()));
            normalIcon  = backpack.backpackIcons.GetSprite(config.normalSpritePath.Trim());
            disableIcon = backpack.backpackIcons.GetSprite(config.disableSpritePath.Trim());

            Icon.sprite = normalIcon;

            txtName.text = config.Name;

            if (txtNumber != null)
            {
                txtNumber.text = config.number.ToString();
            }

            _equipmentNumber = config.number;
            //_equipmentName = config.Name;

            GenerateItems = new List <GameObject>();

            if (dataConfig.isGenerate)
            {
                for (int i = 0; i < dataConfig.generateCount; i++)
                {
                    CreateEquipment();
                }
            }

            //刷新
            RefreshShow();
        }