protected override void OnApply()
        {
            SetHighLight(false);
            target.gameObject.SetActive(CellData != null);
            ApplySize();

            if (CellData == null)
            {
                cellImage.gameObject.SetActive(false);
                background.gameObject.SetActive(false);
            }
            else
            {
                // update cell image
                if (currentImageAsset != CellData.ImageAsset)
                {
                    currentImageAsset = CellData.ImageAsset;

                    cellImage.gameObject.SetActive(false);
                    if (Loader == null)
                    {
                        Loader = new StandardAssetLoader();
                    }

                    StartCoroutine(Loader.LoadAsync(CellData.ImageAsset, tex =>
                    {
                        cellImage.texture = tex;
                        cellImage.gameObject.SetActive(true);
                    }));
                }

                background.gameObject.SetActive(true && isSelectable);
            }
        }
예제 #2
0
        public virtual IEnumerator LoadAsync(IVariableInventoryAsset imageAsset, Action <Texture2D> onLoad)
        {
            var loader = Resources.LoadAsync <Texture2D>((imageAsset as StandardAsset).Path);

            yield return(loader);

            onLoad(loader.asset as Texture2D);
        }
예제 #3
0
        public ItemCellData(int sampleSeed)
        {
            switch (sampleSeed)
            {
            case 0:
                Width      = 2;
                Height     = 1;
                ImageAsset = new VariableInventorySystem.StandardAsset("Image/handgun");
                break;

            case 1:
                Width      = 2;
                Height     = 1;
                ImageAsset = new VariableInventorySystem.StandardAsset("Image/handgun2");
                break;

            case 2:
                Width      = 4;
                Height     = 2;
                ImageAsset = new VariableInventorySystem.StandardAsset("Image/rifle");
                break;

            case 3:
                Width      = 5;
                Height     = 2;
                ImageAsset = new VariableInventorySystem.StandardAsset("Image/sniper");
                break;

            case 4:
                Width      = 2;
                Height     = 2;
                ImageAsset = new VariableInventorySystem.StandardAsset("Image/submachinegun");
                break;

            case 5:
                Width      = 2;
                Height     = 1;
                ImageAsset = new VariableInventorySystem.StandardAsset("Image/handgun");
                break;

            case 6:
                Width      = 2;
                Height     = 1;
                ImageAsset = new VariableInventorySystem.StandardAsset("Image/handgun2");
                break;
            }
        }