Example #1
0
    AudioClip GetAudioClip(string _tag)
    {
        if (!soundDic.ContainsKey(_tag))
        {
            //Resources 경로 설정
            SoundTable.SoundInfo soundInfo = soundTable.GetSoundInfo(_tag);
            if (soundInfo == null)
            {
                Debug.LogError("Not found SoundInfo : " + _tag);
                return(null);
            }

            //AssetBundle 에서 오디오클립 로드
            AudioClip newClip = ResourceManager.LoadAsset(soundInfo.path, soundInfo.tag, resLinkType) as AudioClip;

            if (newClip == null)
            {
                Debug.LogError("Not found Audioclip : " + _tag);
                return(null);
            }

            //Table 에 추가
            soundDic.Add(_tag, newClip);
        }

        return(soundDic[_tag]);
    }
Example #2
0
    static bool ReadExcelFile(string excelPath, string prefabPath)
    {
        lastMsg = string.Empty;

        try
        {
            Excel itemData = ExcelHelper.LoadExcel(excelPath);

            if (itemData == null)
            {
                return(false);
            }

            List <ExcelTable> itemDataTable = itemData.Tables;

            string           prefabFilePath = prefabPath + "/SoundTable.asset";
            ScriptableObject soundTableSO   = (ScriptableObject)AssetDatabase.LoadAssetAtPath(prefabFilePath, typeof(ScriptableObject));
            if (soundTableSO == null)
            {
                soundTableSO = ScriptableObject.CreateInstance <SoundTable>();
                AssetDatabase.CreateAsset(soundTableSO, prefabFilePath);
                soundTableSO.hideFlags = HideFlags.NotEditable;
            }

            SoundTable soundDataTable = (SoundTable)soundTableSO;

            soundDataTable.soundInfoList.Clear();

            if (itemDataTable.Count > 0)
            {
                for (int i = 0; i < itemDataTable.Count; i++)
                {
                    if (itemDataTable[i].TableName == "KR")
                    {
                        int indexColumn = 0;
                        int pathColumn  = 0;
                        int tagColumn   = 0;

                        for (int column = 1; column <= itemDataTable[i].NumberOfColumns; column++)
                        {
                            if (Convert.ToString(itemDataTable[i].GetValue(1, column)) == "Index")
                            {
                                indexColumn = column;
                            }
                            if (Convert.ToString(itemDataTable[i].GetValue(1, column)) == "Path")
                            {
                                pathColumn = column;
                            }
                            if (Convert.ToString(itemDataTable[i].GetValue(1, column)) == "Tag")
                            {
                                tagColumn = column;
                            }
                        }

                        for (int row = 2; row <= itemDataTable[i].NumberOfRows; row++)
                        {
                            if (Convert.ToString(itemDataTable[i].GetValue(row, indexColumn)).Equals(""))
                            {
                                continue;
                            }

                            int    index = Convert.ToInt32(itemDataTable[i].GetValue(row, indexColumn));
                            string path  = Convert.ToString(itemDataTable[i].GetValue(row, pathColumn));
                            string tag   = Convert.ToString(itemDataTable[i].GetValue(row, tagColumn));

                            SoundTable.SoundInfo soundInfo = new SoundTable.SoundInfo();

                            soundInfo.index = index;
                            soundInfo.path  = path;
                            soundInfo.tag   = tag;

                            soundDataTable.soundInfoList.Add(soundInfo);
                        }
                    }
                }

                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();

                EditorUtility.SetDirty(soundTableSO);
                lastMsg = "Succeeded import data to prefab file : " + prefabFilePath;
            }
            else
            {
                lastMsg = "Result : Fail. Reason : Data was not found.";
            }

            return(true);
        } catch (Exception e)
        {
            UnityEngine.Debug.Log(e.Message);
            lastMsg = "Result : fail\nMessage : " + e.Message;
            return(false);
        } finally {
        }
    }