Esempio n. 1
0
        public static void Init()
        {
            Logging.LogInfo("Asset Database", "Loading Asset Database!");
            if (System.IO.File.Exists("AssetDatabase.xml"))
            {
                XMLAbstraction data = new XMLAbstraction("AssetDatabase", "AssetDatabase.xml");

                //Load IDs
                currentID = Convert.ToInt32(data.GetNode("//AssetDatabase/IDs/CurrentID").InnerText);
                var deletedIDNodes = data.GetNodes("//AssetDatabase/IDs/DeletedIDs/ID");
                foreach (var n in deletedIDNodes)
                {
                    deletedIDs.Add(Convert.ToInt32(n.InnerText));
                }

                //Load Assets
                var assetNodes = data.GetNodes("//AssetDatabase/Assets/*[local-name()='Asset']");
                foreach (var asset in assetNodes)
                {
                    string type = asset.GetAttribute("type");
                    if (IsTypeAtomic(type))
                    {
                        atomicAssetsInProject.Add(new Tuple <string, string, int>(asset.GetAttribute("path"), type, Convert.ToInt32(asset.GetAttribute("id"))));
                    }
                    else
                    {
                        composedAssetsInProject.Add(new Tuple <string, string, int>(asset.GetAttribute("path"), type, Convert.ToInt32(asset.GetAttribute("id"))));
                    }
                }
            }
            else
            {
                Logging.LogError("Asset Database", "Could not find AssetDatabase.xml!");
            }
        }
Esempio n. 2
0
        public Material(string path) : base(path)
        {
            shader   = null;
            Uniforms = new List <Shader.Uniform>();
            XMLAbstraction xml        = new XMLAbstraction("Material", path);
            var            shaderNode = xml.GetNode("//Material/Shader");

            if (shaderNode != null)
            {
                SetShader(AssetDatabase.GetAsset(Convert.ToInt32(shaderNode.InnerText)) as Shader);
            }
            foreach (var n in xml.GetNodes("//Material/Uniforms/Uniform"))
            {
                Type t = Type.GetType(n.GetAttribute("type"));
                if (t.IsSubclassOf(typeof(Asset)))
                {
                    SetUniform(n.GetAttribute("name"), AssetDatabase.GetAsset(TypeSerialization.DeserializePrimitiveType <int>(n.node)));
                }
                else
                {
                    SetUniform(n.GetAttribute("name"), TypeSerialization.DeserializeType(n.node, t));
                }
            }
        }