/// <summary> /// /// </summary> /// <param name="buttonsInfo"></param> /// <param name="newLayer"></param> private void SetupLayerIcons(sButtonsInfo buttonsInfo, GameObject newLayer) { int btnAmt = GetAmtOfMaterials(buttonsInfo.itemIfCraftType.craftMaterialInfo); iconRotations = CraftWheelUtils.SetIconOffsets(btnAmt + 1); CreateIcons(btnAmt, buttonsInfo, newLayer); }
// MakeIconLayer gets called right after CraftMenuInnerLayer sets the itemToCreate here // and then the craft layer is set to active right after Icons are created /// <summary> /// /// </summary> /// <param name="buttonsInfo"></param> /// <returns></returns> public GameObject MakeIconLayer(sButtonsInfo buttonsInfo) { craftIconLayer = new GameObject("CraftIconLayer"); craftIconLayer.transform.SetParent(gameObject.transform, false); SetupLayerIcons(buttonsInfo, craftIconLayer); return(craftIconLayer); }
/// <summary> /// /// </summary> /// <param name="btnAmt"></param> /// <param name="buttonsInfo"></param> /// <param name="layer"></param> private void CreateIcons(int btnAmt, sButtonsInfo buttonsInfo, GameObject layer) { // Add one to account for Back button int btnLength = btnAmt + 1; GameObject[] newIconButtons = new GameObject[btnLength]; for (int i = 0; i < btnLength; i++) { // Reverse the indices int btnIndex = btnLength - 1 - i; Vector3 iconPosition; Quaternion iconRotation; CraftWheelUtils.GetCraftBtnPosition(btnLength, btnIndex, iconRotations[0], menuCenterPos, iconDistributionRadius, out iconPosition, out iconRotation); Vector3 btnPosition; Quaternion btnRotation; CraftWheelUtils.GetCraftBtnPosition(btnLength, btnIndex, iconRotations[1], menuCenterPos, iconDistributionRadius, out btnPosition, out btnRotation); Image separator = Instantiate(separatorIcon, iconPosition, iconRotation *= iconLocalRotOffset); separator.name = "MenuSeparatorIcon"; separator.transform.SetParent(layer.transform, false); GameObject tmpIcon = new GameObject("tmpIcon", typeof(Image)); // GameObject curIcon; // MenuCreateButton curMBC; Item tmpMaterial; switch (i) { case 0: tmpIcon.GetComponent <Image>().sprite = backIcon; tmpIcon.name = "BackIcon"; tmpIcon.transform.position = btnPosition; tmpIcon.transform.SetParent(layer.transform, false); backButton = tmpIcon; break; case 1: tmpMaterial = buttonsInfo.itemIfCraftType.craftMaterialInfo.firstMaterial; tmpIcon.GetComponent <Image>().sprite = tmpMaterial.icon; tmpIcon.name = tmpMaterial.itemName; tmpIcon.transform.position = btnPosition; tmpIcon.transform.SetParent(layer.transform, false); break; case 2: tmpMaterial = buttonsInfo.itemIfCraftType.craftMaterialInfo.secondMaterial; tmpIcon.GetComponent <Image>().sprite = tmpMaterial.icon; tmpIcon.name = tmpMaterial.itemName; tmpIcon.transform.position = btnPosition; tmpIcon.transform.SetParent(layer.transform, false); break; case 3: tmpMaterial = buttonsInfo.itemIfCraftType.craftMaterialInfo.thirdMaterial; tmpIcon.GetComponent <Image>().sprite = tmpMaterial.icon; tmpIcon.name = tmpMaterial.itemName; tmpIcon.transform.position = btnPosition; tmpIcon.transform.SetParent(layer.transform, false); break; } } }