Example #1
0
        public List <T> LoadCSVNoCache <T>(ResourceID resID) where T : CSVBaseData
        {
            UnityEngine.Object resourceObj = ResourceManager.Instance.GetResource(resID);
            if (resourceObj == null)
            {
                return(null);
            }
            string    csvText      = "";
            TextAsset csvTextAsset = UnityEngine.Object.Instantiate(resourceObj) as TextAsset;

            byte[] csv_bs;

#if ENABLE_ENCRYPTION
            ResDecryption.Decryption(csvTextAsset.bytes, out csv_bs);
#else
            csv_bs = csvTextAsset.bytes;
#endif
            csvText = Encoding.UTF8.GetString(csv_bs);

            if (string.IsNullOrEmpty(csvText))
            {
                return(null);
            }

            return(ParseCSV <T>(csvText));
        }
Example #2
0
        public void LoadCSV <T>(ResourceID resID) where T : CSVBaseData
        {
            string typeKey = GetDataListsKey <T>();

            if (m_ConfigDataLists.ContainsKey(typeKey))
            {
                Debug.LogWarning("duplicated key in config: " + typeKey);
                return;
            }
            List <T> result = LoadCSVNoCache <T>(resID);

            if (result != null)
            {
                List <CSVBaseData> list = new List <CSVBaseData>();
                for (int i = 0; i < result.Count; i++)
                {
                    CSVBaseData item = result[i];
                    list.Add(item);
                    string pKey = item.GetPrimaryKey();
                    if (string.IsNullOrEmpty(pKey) == false)
                    {
                        string itemKey = GetDataItemKey <T>(pKey);
                        if (m_ConfigDataItemss.ContainsKey(itemKey) == false)
                        {
                            m_ConfigDataItemss.Add(itemKey, item);
                        }
                        else
                        {
                            Debug.Log("duplicate item key: " + itemKey);
                        }
                    }
                }
                m_ConfigDataLists.Add(typeKey, list);
            }
        }
Example #3
0
 public Object GetResource(ResourceID id)
 {
     if (id != ResourceID.INVALID)
     {
         return(Resources.Load(id));
     }
     else
     {
         return(null);
     }
 }
Example #4
0
        protected T CreateView <T>() where T : UIBaseView, new()
        {
            System.Reflection.MemberInfo info = typeof(T);
            object[] attributes = info.GetCustomAttributes(true);
            T        m_view     = null;

            foreach (var attribute in attributes)
            {
                UIResourceAttribute resourceInfo = (UIResourceAttribute)attribute;
                if (resourceInfo != null)
                {
                    ResourceID         id         = ResourceManager.Instance.GetResourceIDbyPath(resourceInfo.ResID);
                    UnityEngine.Object res        = ResourceManager.Instance.GetResource(id);
                    GameObject         viewObject = UnityEngine.Object.Instantiate(res) as GameObject;
                    m_view = viewObject.GetComponent <T>();
                    m_view.Init(UISceneBase.UIRoot);
                }
            }
            return(m_view);
        }