Beispiel #1
0
    void SetNextLine()
    {
        Island01ConversationData.Param selifInfo = selifInformationList[currentLine];

        //プレハブの生成
        GameObject selifObj = (GameObject)Instantiate(selifPrefab);

        selifObj.transform.SetParent(containerSelif.transform);
        selifObj.transform.SetSiblingIndex(0);         //一番上に持ってくる
        selifObj.transform.localScale = new Vector3(1, 1, 1);
        //左右
        GameObject leftArrow      = selifObj.transform.GetChild(0).gameObject;
        GameObject rightArrow     = selifObj.transform.GetChild(1).gameObject;
        GameObject leftCharacter  = backGround.transform.GetChild(0).GetChild(0).gameObject;
        GameObject rightCharacter = backGround.transform.GetChild(0).GetChild(1).gameObject;

        if (selifInfo.Position == "left")
        {
            //左だったら左を表示して右を非表示
            leftArrow.SetActive(true);
            rightArrow.SetActive(false);
            //イラスト変更
            leftCharacter.GetComponent <Image>().sprite =
                Resources.Load <Sprite>("Img_Character/" + selifInfo.No);
            leftCharacter.GetComponent <CharacterAnimation>().AnimationStart();
        }
        else
        {
            //右だったらその逆
            leftArrow.SetActive(false);
            rightArrow.SetActive(true);
            //イラスト変更
            rightCharacter.GetComponent <Image>().sprite =
                Resources.Load <Sprite>("Img_Character/" + selifInfo.No);
            rightCharacter.GetComponent <CharacterAnimation>().AnimationStart();
        }
        //名前
        GameObject txt_speakerName = selifObj.transform.GetChild(2).GetChild(0).gameObject;

        txt_speakerName.GetComponent <Text>().text = selifInfo.Name;
        //セリフテキスト
        string selifStr = selifInfo.Selif;

        string[] del = { "@n" };                                     //改行するときに使用する文字列
        string[] arr = selifStr.Split(del, StringSplitOptions.None); //セリフを改行文字で分割
        currentText = "";
        for (int i = 0; i < arr.Length; i++)
        {
            currentText += arr[i];
            if (i != arr.Length - 1)
            {
                currentText += "\n";
            }
        }
        uiText = selifObj.transform.GetChild(3).gameObject.GetComponent <Text>();
        //改行数に合わせてボックスの高さを変更
        Vector2 nowSizeDelta = selifObj.GetComponent <RectTransform>().sizeDelta;

        uiText.text = currentText;
        float preferredHeight = uiText.preferredHeight;

        selifObj.GetComponent <RectTransform>().sizeDelta = new Vector2(nowSizeDelta.x,
                                                                        topMargin_txtSelif + preferredHeight + bottomMargin_txtSelif);
        uiText.text = "";
        //その他の情報
        timeUntilDisplay = currentText.Length * intervalForCharacterDisplay;
        timeElapsed      = Time.time;
        currentLine++;
        lastUpdateCharacter = -1;

        StartCoroutine(DelayMethod(0.2f, () => {
            canDisplayText = true;
        }));
    }
Beispiel #2
0
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (string asset in importedAssets)
        {
            if (!filePath.Equals(asset))
            {
                continue;
            }

            Island01ConversationData data = (Island01ConversationData)AssetDatabase.LoadAssetAtPath(exportPath, typeof(Island01ConversationData));
            if (data == null)
            {
                data = ScriptableObject.CreateInstance <Island01ConversationData> ();
                AssetDatabase.CreateAsset((ScriptableObject)data, exportPath);
                data.hideFlags = HideFlags.NotEditable;
            }

            data.sheets.Clear();
            using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
                IWorkbook book = null;
                if (Path.GetExtension(filePath) == ".xls")
                {
                    book = new HSSFWorkbook(stream);
                }
                else
                {
                    book = new XSSFWorkbook(stream);
                }

                foreach (string sheetName in sheetNames)
                {
                    ISheet sheet = book.GetSheet(sheetName);
                    if (sheet == null)
                    {
                        Debug.LogError("[QuestData] sheet not found:" + sheetName);
                        continue;
                    }

                    Island01ConversationData.Sheet s = new Island01ConversationData.Sheet();
                    s.name = sheetName;

                    for (int i = 1; i <= sheet.LastRowNum; i++)
                    {
                        IRow  row  = sheet.GetRow(i);
                        ICell cell = null;

                        Island01ConversationData.Param p = new Island01ConversationData.Param();

                        cell = row.GetCell(0); p.No = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(1); p.Name = (cell == null ? "" : cell.StringCellValue);
                        cell = row.GetCell(2); p.Position = (cell == null ? "" : cell.StringCellValue);
                        cell = row.GetCell(3); p.Selif = (cell == null ? "" : cell.StringCellValue);
                        s.list.Add(p);
                    }
                    data.sheets.Add(s);
                }
            }

            ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject;
            EditorUtility.SetDirty(obj);
        }
    }