Пример #1
0
        public void ExtractRawText(SerializeObject obj, string outputPath)
        {
            if (Path.GetFileName(outputPath) == "")
            {
                var    nameProperty = obj.FindProperty("m_Name");
                string name         = "";
                if (nameProperty != null)
                {
                    name = nameProperty.Value as string;
                }
                if (string.IsNullOrEmpty(name))
                {
                    name = (gID++).ToString();
                }
                outputPath += "/" + name;
            }
            if (Path.GetExtension(outputPath) == "")
            {
                outputPath += ".txt";
            }
            outputPath = AssetToolUtility.FixOuputPath(outputPath);
            string content = obj.ToString();

            if (!Directory.Exists(Path.GetDirectoryName(outputPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
            }
            var bytes = System.Text.Encoding.Unicode.GetBytes(content);
            var fs    = new FileStream(outputPath, FileMode.OpenOrCreate, FileAccess.Write);

            fs.Write(bytes, 0, bytes.Length);
            fs.Flush();
            fs.Dispose();
        }
Пример #2
0
 private void extractOnlyRawBits(Asset.AssetObjectInfo objinfo, TypeTree typeTree, string outputPath)
 {
     string name = "";
     if (typeTree != null && Path.GetFileName(outputPath) == "") {           
         try {
             SerializeObject sobj  = new SerializeObject(typeTree, objinfo.data);
            var nameProperty = sobj.FindProperty("m_Name");              
             if (nameProperty != null) {
                 name = nameProperty.Value as string;
                 outputPath += "/" + name;
             }
         } catch {
             Debug.LogError("Can't Create SerializeObject.TypeVerion:{0},TypeClassID:{1},TypeName:{2}",
                 typeTree.version, objinfo.classID, typeTree.type);
         }
     }
     ExtractRawBits(objinfo, outputPath);
 }
Пример #3
0
        private void extractOnlyRawBits(Asset.AssetObjectInfo objinfo, TypeTree typeTree, string outputPath)
        {
            string name = "";

            if (typeTree != null && Path.GetFileName(outputPath) == "")
            {
                try {
                    SerializeObject sobj         = new SerializeObject(typeTree, objinfo.data);
                    var             nameProperty = sobj.FindProperty("m_Name");
                    if (nameProperty != null)
                    {
                        name        = nameProperty.Value as string;
                        outputPath += "/" + name;
                    }
                } catch {
                    Debug.LogError("Can't Create SerializeObject.TypeVerion:{0},TypeClassID:{1},TypeName:{2}",
                                   typeTree.version, objinfo.classID, typeTree.type);
                }
            }
            ExtractRawBits(objinfo, outputPath);
        }
Пример #4
0
        public void ExtractRawText(SerializeObject obj, string outputPath)
        {

            if (Path.GetFileName(outputPath) == "") {
                var nameProperty = obj.FindProperty("m_Name");
                string name = "";
                if (nameProperty != null) {
                    name = nameProperty.Value as string;
                }
                if (string.IsNullOrEmpty(name)) {
                    name = (gID++).ToString();
                }
                outputPath += "/" + name;
            }
            if (Path.GetExtension(outputPath) == "") {
                outputPath += ".txt";
            }     
            outputPath = AssetToolUtility.FixOuputPath(outputPath);
            string content = obj.ToString();
            if (!Directory.Exists(Path.GetDirectoryName(outputPath))) {
                Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
            }
            var bytes = System.Text.Encoding.Unicode.GetBytes(content);
            var fs = new FileStream(outputPath, FileMode.OpenOrCreate, FileAccess.Write);
            fs.Write(bytes, 0, bytes.Length);
            fs.Flush();
            fs.Dispose();
        }