private void ProcessRecord(string outputRecordPath)
        {
            string recordPath = Icarus.GameFramework.Utility.Path.GetCombinePath(outputRecordPath, string.Format("{0}_{1}.xml", RecordName, ApplicableGameVersion.Replace('.', '_')));

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.AppendChild(xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null));

            XmlAttribute xmlAttribute = null;
            XmlElement   xmlRoot      = xmlDocument.CreateElement("ResourceVersionInfo");

            xmlAttribute       = xmlDocument.CreateAttribute("ApplicableGameVersion");
            xmlAttribute.Value = ApplicableGameVersion.ToString();
            xmlAttribute       = xmlDocument.CreateAttribute("MinAppVersion");
            xmlAttribute.Value = MinAppVersion.ToString();
            xmlRoot.Attributes.SetNamedItem(xmlAttribute);
            xmlAttribute       = xmlDocument.CreateAttribute("LatestInternalResourceVersion");
            xmlAttribute.Value = InternalResourceVersion.ToString();
            xmlRoot.Attributes.SetNamedItem(xmlAttribute);
            xmlDocument.AppendChild(xmlRoot);

            xmlDocument.Save(recordPath);
        }
        public bool Save()
        {
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.AppendChild(xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null));

                XmlElement xmlRoot = xmlDocument.CreateElement("UnityGameFramework");
                xmlDocument.AppendChild(xmlRoot);

                XmlElement xmlBuilder = xmlDocument.CreateElement("AssetBundleBuilder");
                xmlRoot.AppendChild(xmlBuilder);

                XmlElement xmlSettings = xmlDocument.CreateElement("Settings");
                xmlBuilder.AppendChild(xmlSettings);

                XmlElement xmlElement = null;

                xmlElement           = xmlDocument.CreateElement("InternalResourceVersion");
                xmlElement.InnerText = InternalResourceVersion.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("MinAppVersion");
                xmlElement.InnerText = MinAppVersion.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("WindowsSelected");
                xmlElement.InnerText = WindowsSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("MacOSXSelected");
                xmlElement.InnerText = MacOSXSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("IOSSelected");
                xmlElement.InnerText = IOSSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("AndroidSelected");
                xmlElement.InnerText = AndroidSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("WindowsStoreSelected");
                xmlElement.InnerText = WindowsStoreSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("RecordScatteredDependencyAssetsSelected");
                xmlElement.InnerText = RecordScatteredDependencyAssetsSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("UncompressedAssetBundleSelected");
                xmlElement.InnerText = UncompressedAssetBundleSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("DisableWriteTypeTreeSelected");
                xmlElement.InnerText = DisableWriteTypeTreeSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("DeterministicAssetBundleSelected");
                xmlElement.InnerText = DeterministicAssetBundleSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("ForceRebuildAssetBundleSelected");
                xmlElement.InnerText = ForceRebuildAssetBundleSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("IgnoreTypeTreeChangesSelected");
                xmlElement.InnerText = IgnoreTypeTreeChangesSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("AppendHashToAssetBundleNameSelected");
                xmlElement.InnerText = AppendHashToAssetBundleNameSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("ChunkBasedCompressionSelected");
                xmlElement.InnerText = ChunkBasedCompressionSelected.ToString();
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("BuildEventHandlerTypeName");
                xmlElement.InnerText = BuildEventHandlerTypeName;
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("OutputDirectory");
                xmlElement.InnerText = OutputDirectory;
                xmlSettings.AppendChild(xmlElement);
                xmlElement           = xmlDocument.CreateElement("CopyStreamingAssets");
                xmlElement.InnerText = IsCopyStreamingAssets.ToString();
                xmlSettings.AppendChild(xmlElement);

                string configurationDirectoryName = Path.GetDirectoryName(m_ConfigurationPath);
                if (!Directory.Exists(configurationDirectoryName))
                {
                    Directory.CreateDirectory(configurationDirectoryName);
                }

                xmlDocument.Save(m_ConfigurationPath);
                AssetDatabase.Refresh();
                return(true);
            }
            catch
            {
                if (File.Exists(m_ConfigurationPath))
                {
                    File.Delete(m_ConfigurationPath);
                }

                return(false);
            }
        }
Ejemplo n.º 3
0
        private void OnGUI()
        {
            EditorGUILayout.LabelField("Transfer Params", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical("box");
            {
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("AssetBundle SrcOutputPath", GUILayout.Width(160f));
                    if (IsValidOutputDirectory)
                    {
                        GUILayout.TextArea(string.Format("{0}", OutputDirectory));
                    }
                    else
                    {
                        GUILayout.Label("Please choose your assetbundle output directory first!");
                    }
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("AssetBundle TargetPath", GUILayout.Width(160f));
                    GUILayout.TextArea(Application.streamingAssetsPath);
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Internal Resource Version", GUILayout.Width(160f));
                    InternalResourceVersion = EditorGUILayout.IntField(InternalResourceVersion);
                }
                EditorGUILayout.EndHorizontal();


                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Resource Version", GUILayout.Width(160f));
                    GUILayout.Label(string.Format("{0}_{1}", "1.0".Replace('.', '_'), InternalResourceVersion.ToString()));
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    displayResourceMode = (ResourceMode)EditorGUILayout.EnumPopup("Resource Mode", displayResourceMode);
                }
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(2f);

                EditorGUILayout.BeginHorizontal();
                {
                    displayPlatform = (BuildTarget)EditorGUILayout.EnumPopup("Platform", displayPlatform);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();


            GUILayout.Space(50f);

            EditorGUILayout.BeginVertical("box");
            {
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUI.BeginDisabledGroup(!IsValidOutputDirectory || displayResourceMode == ResourceMode.Unspecified);
                    {
                        if (GUILayout.Button("Start Transfer AssetBundles"))
                        {
                            TransferAssetBundlesToStreamingAssets(OutputDirectory, displayResourceMode, displayPlatform, string.Format("{0}_{1}", "1.0".Replace('.', '_'), InternalResourceVersion.ToString()));
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
        }