private void OnEnable() { while (0 < content.childCount) { Transform child = content.GetChild(0); child.SetParent(null); GameObject.Destroy(child.gameObject); } foreach (var itr in AchieveManager.Instance.achieves) { GameObject obj = GameObject.Instantiate <GameObject>(slot_prefab); UISlot slot = obj.AddComponent <UISlot>(); slot.Init(itr.Value); slot.transform.SetParent(content, false); } scrollbar.value = 1.0f; /* * for (int i = 0; i < 10; i++) * { * GameObject obj = GameObject.Instantiate<GameObject>(slot_prefab); * UISlot slot = obj.AddComponent<UISlot>(); * slot.Init(null); * slot.transform.SetParent(content, false); * } */ }
/// <summary> /// Sets a unit to the new slot position from the first UI Slot. /// </summary> /// <param name="_slot">Hands over the new slot for the unit.</param> private void NewUISlot(UISlot _slot) { if (_slot == UISlotFirst || _slot == null || UISlotFirst == null) { return; } if (_slot.GetID >= 0) { } else { _slot.Init(UISlotFirst.GetSprite, UISlotFirst.GetID); UISlotFirst.RemoveUnit(); UISlotFirst.SetDefaultSprite(); OnUnitChanged?.Invoke(UISlotFirst.GetSlotId, _slot.GetSlotId); } }