public virtual void CreateMenuItem(Canvas canvas, ButtonsInfo info, LabelInformation labelInfo, bool open) { string[] filePath = labelInfo.buttonImageFile; buttonImage = new Image[filePath.Length]; rectTransform = new RectTransform[buttonImage.Length]; alphaAmount = new float[buttonImage.Length]; information = info; for (int i = 0; i < buttonImage.Length; i++) { GameObject buttonObject = new GameObject(); buttonObject.name = filePath[i]; buttonObject.transform.parent = canvas.transform; buttonImage[i] = buttonObject.AddComponent <Image> (); rectTransform[i] = buttonObject.GetComponent <RectTransform> (); if (open) { buttonImage[i].sprite = Resources.Load(defaultPath + filePath[i], typeof(Sprite)) as Sprite; } else { buttonImage[i].sprite = Resources.Load(defaultPath + "stage_notpen", typeof(Sprite)) as Sprite; } rectTransform[i].anchorMax = Vector2.zero; rectTransform[i].anchorMin = Vector2.zero; rectTransform[i].pivot = new Vector2(information.pivot[0] / 2f, information.pivot[1] / 2f); rectTransform[i].position = new Vector3(information.position.x * ratio_width, information.position.y * ratio_height, 0f); rectTransform[i].sizeDelta = new Vector2(information.size.x * ratio_width, information.size.y * ratio_height); buttonImage[i].color = new Color(1, 1, 1, 0f); } }
public CharacterData(JsonData data) { open = (bool)data["open"]; audio = JsonMapper.ToObject <string[]> (data["audio"].ToJson()); status = JsonMapper.ToObject <CharacterStatus> (data["status"].ToJson()); attackInfo = JsonMapper.ToObject <AttackInformation[]> (data["AttackInfo"].ToJson()); labelInfo = JsonMapper.ToObject <LabelInformation> (data["LabelInfo"].ToJson()); }
public BattleUI(LabelInformation info, DataManager dataMan) { dataManager = dataMan; GameObject canvasObject = MonoBehaviour.Instantiate(Resources.Load("Prefabs/BattleUICanvas", typeof(GameObject))) as GameObject; canvas = canvasObject.GetComponent <Canvas> (); GameObject canvasM = new GameObject(); canvasM.name = "battleMapCanvas"; battleMapCanvas = canvasM.AddComponent <Canvas> (); battleMapCanvas.renderMode = RenderMode.ScreenSpaceOverlay; for (int i = 0; i < canvasObject.transform.childCount; i++) { Image image = canvasObject.transform.GetChild(i).GetComponent <Image> (); image.rectTransform.position = new Vector3(image.rectTransform.position.x * ratio_width, image.rectTransform.position.y * ratio_height, 0f); image.rectTransform.sizeDelta = new Vector2(image.rectTransform.sizeDelta.x * ratio_width, image.rectTransform.sizeDelta.y * ratio_height); if (image.transform.childCount > 0) { for (int j = 0; j < image.transform.childCount; j++) { Image child = image.transform.GetChild(j).GetComponent <Image> (); child.rectTransform.position = new Vector3(child.rectTransform.position.x * ratio_width, child.rectTransform.position.y * ratio_height, 0f); child.rectTransform.sizeDelta = new Vector2(child.rectTransform.sizeDelta.x * ratio_width, child.rectTransform.sizeDelta.y * ratio_height); } } } fieldSize = new Vector2(FIELD_MAX_X - FIELD_MIN_X, FIELD_MAX_Z - FIELD_MIN_Z); mapSize = new Vector2(MAP_MAX_X - MAP_MIN_X, MAP_MAX_Z - MAP_MIN_Z); bigMapSize = new Vector2(BMAP_MAX_X - BMAP_MIN_X, BMAP_MAX_Z - BMAP_MIN_Z); mapRatio = new Vector2(mapSize.x / bigMapSize.x, mapSize.y / bigMapSize.y); Image miniMap = canvasObject.transform.Find("minimap").GetComponent <Image> (); miniMap.transform.SetParent(battleMapCanvas.transform); Image face = canvasObject.transform.Find("chara_image").GetComponent <Image> (); face.sprite = Resources.Load("UserInterface/" + info.faceImageFile, typeof(Sprite)) as Sprite; Image name = canvasObject.transform.Find("chara_name").GetComponent <Image> (); name.sprite = Resources.Load("UserInterface/" + info.buttonImageFile[0], typeof(Sprite)) as Sprite; player_maker = canvasObject.transform.Find("unit_player").GetComponent <Image> (); player_maker.transform.SetParent(battleMapCanvas.transform); hpGauge = canvasObject.transform.Find("gauge_hp").GetComponent <Image> (); result = canvasObject.transform.Find("result").GetComponent <Image> (); killNumber = new Image[3]; for (int i = 0; i < killNumber.Length; i++) { killNumber[i] = canvasObject.transform.Find("killer_number00" + (i + 1).ToString()).GetComponent <Image> (); killNumber[i].color = new Color(1, 1, 1, 0); } killNumber[0].sprite = Resources.Load(fileName[0], typeof(Sprite)) as Sprite; killNumber[0].color = new Color(1, 1, 1, 1); //SetMapSize (true); battleMenu = new ManualMenu(new string[3] { "Other/manual_op", "Other/manual_op2", "Other/manual_op3" }); battleMenu.CreateCanvas(dataManager); }