Exemplo n.º 1
0
        internal static string GetDirPath(System.Type t)
        {
            var    attr = ConfigLoader.GetConfigAttribute(t);
            string path = string.Format("{0}/{1}", UTIL_DIR, attr.filename);

            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }
            return(path);
        }
Exemplo n.º 2
0
        internal static List <TypeAndAttr> GetTypeList()
        {
            List <TypeAndAttr> list = new List <TypeAndAttr>();
            var domain = System.AppDomain.CurrentDomain;

            foreach (var asm in domain.GetAssemblies())
            {
                var types = asm.GetTypes();
                foreach (var type in types)
                {
                    var customAttr = ConfigLoader.GetConfigAttribute(type);
                    if (customAttr == null)
                    {
                        continue;
                    }
                    list.Add(new TypeAndAttr(type, customAttr));
                }
            }
            return(list);
        }
Exemplo n.º 3
0
        public static void SaveDataToStreamingAssets(object obj)
        {
            System.Type type       = obj.GetType();
            var         customAttr = ConfigLoader.GetConfigAttribute(type);

            if (customAttr == null)
            {
                return;
            }
            string path = ConfigLoader.GetConfigDataPath(customAttr);

            if (System.IO.File.Exists(path))
            {
                bool res = EditorUtility.DisplayDialog("Overwrite?", "File is already exist.Overwrite?", "ok", "cancel");
                if (!res)
                {
                    return;
                }
            }
            string json = JsonUtility.ToJson(obj);

            System.IO.File.WriteAllText(path, json);
        }