Пример #1
0
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        if (ResourceDB.FindInstance() == null)
        {
            return;
        }
        if (!ResourceDB.Instance.UpdateAutomatically)
        {
            return;
        }
        var  files  = importedAssets.Concat(deletedAssets).Concat(movedAssets).Concat(movedFromAssetPaths);
        bool update = false;

        foreach (var file in files)
        {
            var fn = file.ToLower();
            if (!fn.Contains("resourcedb.asset") && fn.Contains("/resources/"))
            {
                update = true;
                break;
            }
        }
        if (update)
        {
            ResourceDB.Instance.UpdateDB();
        }
    }
Пример #2
0
    public static GameObject Prefab(string prefabName)
    {
        string     path   = prefabName;
        GameObject prefab = _dicPrefabCache.GetValueSafe(path);

        if (prefab == null)
        {
            prefab = Resources.Load <GameObject>(path);
            if (prefab == null)
            {
                try {
                    ResourceItem item = ResourceDB.GetAsset(prefabName);
                    if (item != null)
                    {
                        path = item.ResourcesPath;
                    }
                } catch {
                    Debug.LogWarning("There was a problem reading the Resource Database. Please update the db.");
                    return(null);
                }
                prefab = Resources.Load <GameObject>(path);
            }

            if (prefab == null)
            {
                Debug.LogWarning(prefabName + " prefab does not exisit.");
                return(null);
            }
            _dicPrefabCache[prefabName] = prefab;
        }
        return(prefab);
    }
Пример #3
0
        static void Main(string[] args)
        {
            string dbtype     = ConfigurationHandler.GetValue("DB_Type");
            string dbname     = ConfigurationHandler.GetValue("DB_Name");
            string dbserver   = ConfigurationHandler.GetValue("DB_Server");
            string dbuser     = ConfigurationHandler.GetValue("DB_User");
            string dbpassword = ConfigurationHandler.GetValue("DB_Password");

            dbserver   = dbserver == null ? "localhost" : dbserver;
            dbuser     = dbuser == null ? "root" : dbuser;
            dbpassword = dbpassword == null ? "root" : dbpassword;

            DatabaseManager database_manager = new DatabaseManager(dbtype, dbname, dbserver, dbuser, dbpassword);

            string storage_path = ConfigurationHandler.GetValue("Storage_path");

            ResourceDB res = new ResourceDB(database_manager, storage_path);

            res.Add(new Category(100, "Image", "Resource is a image (Image, Photo etc)"));
            res.Add(new Category(200, "Text", "UTF-8 encoded text"));


            //res.AddImageResource(System.Drawing.Image.FromFile("Z:\\Pictures\\IMG_0538.JPG"));

            //IDatabase db = null;

            //string dbtype = ConfigurationHandler.GetValue("DB");

            //switch (dbtype)
            //{
            //    case "MySql":
            //    default:
            //        db = new MySQLDatabase();
            //        break;
            //}

            //db.Insert();
            //db.Select();

            //// z:\pictures\img_0538.jpg

            /*
             * Info inf = new Info("Z:\\Pictures\\IMG_0538.JPG");
             *
             * foreach (string propertyname in inf.PropertyItems.Keys)
             * {
             *  Debug.WriteLine(propertyname + ": " + (inf.PropertyItems[propertyname]).ToString());
             *  Console.WriteLine(propertyname + ": " + (inf.PropertyItems[propertyname]).ToString());
             *
             * }
             */
        }
Пример #4
0
        private IDictionary GetResourceSet(string CultureName, string ResourceSet)
        {
            if (CultureName == null)
            {
                CultureName = "";
            }

            string     ResourceFilter = "";
            DataTable  dt             = new DataTable();
            ResourceDB resource       = new ResourceDB();

            Dictionary <string, object> hashTable = new Dictionary <string, object>();



            if (string.IsNullOrEmpty(CultureName))
            {
                dt = resource.GetResourceSet(null, ResourceSet);
            }
            else
            {
                dt = resource.GetResourceSet(null, ResourceSet, CultureName);
            }

            if (dt == null)
            {
                return(hashTable as IDictionary);
            }

            try
            {
                foreach (DataRow row in dt.Rows)
                {
                    object ResourceValue = null;
                    ResourceValue = row["ResourceValue"] as string;

                    if (ResourceValue == null)
                    {
                        ResourceValue = "";
                    }

                    hashTable.Add(row["ResourceKey"].ToString(), ResourceValue);
                }
            }
            catch { }


            return(hashTable as IDictionary);
        }
Пример #5
0
 internal void OnDeserialize()
 {
     if (string.IsNullOrEmpty(path))
     {
         parent = ResourceDB.Instance.root;
     }
     else
     {
         parent = ResourceDB.GetFolder(path);
     }
     if (parent != null)
     {
         parent.childs.Add(name, this);
     }
     if (type == Type.Folder)
     {
         childs = new Dictionary <string, ResourceItem>();
     }
     objectType = System.Type.GetType(objectTypeName);
 }
Пример #6
0
 void OnEnable()
 {
     m_Target = (ResourceDB)target;
 }
Пример #7
0
 public ResourceDB()
 {
     m_Instance = this;
 }