/// <summary> /// ウインドウを作成する /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> private InfoWindow CreateWindowTitle(float x, float y, float z, string message, string url) { message = message.Trim().Replace("\n", ""); //サイズ計算 float width = CulcWindowTitleWidth(message); double div = Math.Ceiling(message.Length / 21.0); float heightImg = TITLE_HEIGHT_IMG_1; if (div >= 3) { heightImg = TITLE_HEIGHT_IMG_3; } else if (div == 2) { heightImg = TITLE_HEIGHT_IMG_2; } else { heightImg = TITLE_HEIGHT_IMG_1; } //ウインドウインスタンスチェック InitInfoWindowInstanse(); //インスタンティエイト GameObject window = Instantiate(this.InfoWindowInstanse) as GameObject; //ウインドウ名設定 window.name = "TitleWindow" + WindowTitleListQ.Count; //位置設定 window.transform.position = new Vector3(x, y, z); //サイズ変更 RectTransform windowRect = window.GetComponent <RectTransform>(); windowRect.sizeDelta = new Vector2(width, heightImg); //スケール設定 window.transform.localScale = new Vector3(1, 1, 1); //ウインドウインスタンス取得 InfoWindow imgWindow = window.GetComponent <InfoWindow>(); //テキスト設定 imgWindow.SetText(message); //親キャンバスに登録 window.transform.SetParent(UiRenderingFront.transform, false); //親ウインドウ登録 imgWindow.SetParentWindow(window); //生成時刻セット imgWindow.SetCreateTime(DateTime.Now); //クリックイベント try { //テキスト サイズ、位置調整 GameObject windowText = window.transform.Find("TitleTalkText").gameObject; //TODO CtrlTalk:CreateWindowTitleここでなぜかエラーが出る 要調査 //windowText.GetComponent<Button>().onClick.AddListener(() => Title_Click(url)); } catch (Exception ex) { Debug.Log(ex.Message); } //結果を返す return(imgWindow); }