예제 #1
0
    ProtoPopupUI GetPopupUI(string _tag)
    {
        ProtoPopupUI popupUI = popupUIList.Find(x => string.Equals(x.name, _tag));

        if (popupUI == null)
        {
            //Resources 경로 설정
            PopupUITable.PopupUIInfo popupUIInfo = popupUITable.GetPopupUIInfo(_tag);
            if (popupUIInfo == null)
            {
                Debug.LogError("Not found PopupUIInfo : " + _tag);
                return(null);
            }

            //string resourcePath = string.Format("{0}{1}", popupUIInfo.path, popupUIInfo.tag);

            GameObject newObj = ResourceManager.LoadAsset(popupUIInfo.path, popupUIInfo.tag, resLinkType) as GameObject;
            if (newObj == null)
            {
                Debug.LogError("Not found popup ui : " + _tag);
                return(null);
            }

            newObj = Instantiate(newObj);

            newObj.name = _tag;
            newObj.transform.SetParent(popupParent);
            newObj.transform.localPosition = Vector3.zero;
            newObj.transform.localRotation = Quaternion.identity;

            popupUI = newObj.GetComponent <ProtoPopupUI>();
            popupUIList.Add(popupUI);
        }

        return(popupUI);
    }
예제 #2
0
    static bool ReadExcelFile(string excelPath, string prefabPath)
    {
        GameObject stringTableInstance = null;

        lastMsg = string.Empty;

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

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

            List <ExcelTable> itemDataTable = itemData.Tables;

            if (itemDataTable.Count > 0)
            {
                for (int i = 0; i < itemDataTable.Count; i++)
                {
                    string           prefabFilePath = prefabPath + "/PopupUITable.asset";
                    ScriptableObject popupUITableSO = (ScriptableObject)AssetDatabase.LoadAssetAtPath(prefabFilePath, typeof(ScriptableObject));
                    if (popupUITableSO == null)
                    {
                        popupUITableSO = ScriptableObject.CreateInstance <PopupUITable>();
                        AssetDatabase.CreateAsset(popupUITableSO, prefabFilePath);
                        popupUITableSO.hideFlags = HideFlags.NotEditable;
                    }

                    PopupUITable popupUIDataTable = (PopupUITable)popupUITableSO;

                    popupUIDataTable.popupUIInfoList.Clear();

                    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));

                        PopupUITable.PopupUIInfo popupUIInfo = new PopupUITable.PopupUIInfo();

                        popupUIInfo.index = index;
                        popupUIInfo.path  = path;
                        popupUIInfo.tag   = tag;

                        popupUIDataTable.popupUIInfoList.Add(popupUIInfo);
                    }

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

                    EditorUtility.SetDirty(popupUITableSO);
                }

                lastMsg = "Succeeded import data to prefab file : PopupUITable";
            }
            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 {
            if (stringTableInstance != null)
            {
                DestroyImmediate(stringTableInstance);
            }
        }
    }