Example #1
0
        /// <summary>
        /// Initialize PartGroup and populate the items.
        /// </summary>
        public void Initialize()
        {
            this.CreatorUI = this.transform.GetComponentInParent <UICreator>();
            if (this.CreatorUI == null)
            {
                return;
            }

            Transform itemparent = getItemParent();
            Dictionary <string, List <Part> > parts = getAvailableParts();
            Part assignedpart = this.CreatorUI.character.GetAssignedPart(slotCategory);

            clearItems();
            selectionObj.gameObject.SetActive(false);

            //..add null
            PartItem partitem = Instantiate <PartItem>(tPartItem, itemparent);

            partitem.Initialize(null);
            if (assignedpart == null)
            {
                selectedItem = partitem;
                if (this.gameObject.activeInHierarchy)
                {
                    StopCoroutine("ie_initselected");
                    StartCoroutine("ie_initselected", selectedItem);
                }
            }
            //add null..

            foreach (string packagename in parts.Keys)
            {
                PackageItem packitem = Instantiate <PackageItem>(tPackage, itemparent);
                packitem.Initialize(packagename);

                foreach (Part part in parts[packagename])
                {
                    partitem = Instantiate <PartItem>(tPartItem, itemparent);
                    partitem.Initialize(part);
                    if (part == assignedpart)
                    {
                        selectedItem = partitem;
                        if (this.gameObject.activeInHierarchy)
                        {
                            StopCoroutine("ie_initselected");
                            StartCoroutine("ie_initselected", selectedItem);
                        }
                    }
                }
            }

            _partcolors = getPartColors();
        }
Example #2
0
        /// <summary>
        /// Updates selected PartItem and UICreator's character part according to the given value.
        /// </summary>
        /// <param name="item">PartItem to be selected.</param>
        public void SelectItem(PartItem item)
        {
            selectedItem = item;
            selectionObj.gameObject.SetActive(true);
            selectionObj.position = item.transform.position;

            Part part = CreatorUI.character.GetAssignedPart(slotCategory);

            if (part != item.part)
            {
                CreatorUI.character.EquipPart(slotCategory, item.part);
            }
        }
Example #3
0
        IEnumerator ie_initselected(PartItem item)
        {
            yield return(null);

            SelectItem(item);
        }