static void Init() { ExportSenceData window = (ExportSenceData)EditorWindow.GetWindow(typeof(ExportSenceData)); window.minSize = new Vector2(300, 300); window.wantsMouseMove = true; window.Show(); }
void OnGUI() { if (GUI.Button(new Rect(600, 15, 150, 20), new GUIContent("清空文件夹"))) { DeleteOutPutFolder(); CreateOutPutFolder(); } EditorGUILayout.LabelField(""); EditorGUILayout.LabelField("Andriod 输出:" + andriodFolder); EditorGUILayout.LabelField(" IOS 输出:" + iosFolder); EditorGUILayout.LabelField(""); EditorGUILayout.LabelField("上一次输出时间:" + projectAssetBundlesInfo.buildTime); EditorGUILayout.LabelField(""); projectAssetBundlesInfo.hiddenDefaultUI = EditorGUILayout.ToggleLeft("Hidden Default UI", projectAssetBundlesInfo.hiddenDefaultUI); EditorGUILayout.LabelField(""); // projectAssetBundlesInfo //projectAssetBundlesInfo // "target" can be any class derrived from ScriptableObject // (could be EditorWindow, MonoBehaviour, etc) // ScriptableObject target = this; SerializedObject so = new SerializedObject(this); SerializedProperty displayProperty = so.FindProperty("needExportScene"); EditorGUILayout.PropertyField(displayProperty, true); // True means show children EditorGUILayout.LabelField(""); displayProperty = so.FindProperty("addCommonAssetBundle"); EditorGUILayout.PropertyField(displayProperty, true); // True means show children so.ApplyModifiedProperties(); // Remember to apply modified properties // Debug.Log(addCommonAssetBundle.Length); EditorGUILayout.LabelField(""); if (GUILayout.Button(new GUIContent("Export"))) { GenScenePath(); sceneAssetBundle = new string[needExportScenePath.Count]; for (int i = 0; i < needExportScenePath.Count; i++) { sceneAssetBundle[i] = needExportScenePath[i].Split('.')[0]; string[] splitStr = sceneAssetBundle[i].Split('/'); sceneAssetBundle[i] = splitStr[splitStr.Length - 1]; sceneAssetBundle[i] = ExportSenceData.GetUTF16(sceneAssetBundle[i]); sceneAssetBundle[i] = sceneAssetBundle[i].ToLower(); AssetImporter assetImporter = AssetImporter.GetAtPath(needExportScenePath[i]); //得到Asset assetImporter.assetBundleName = sceneAssetBundle[i]; //最终设置assetBundleName } projectAssetBundlesInfo.sceneAssetBundle = sceneAssetBundle; projectAssetBundlesInfo.sceneAssetBundleHash = new string[needExportScene.Count]; projectAssetBundlesInfo.sceneAssetBundleCRC = new uint[needExportScene.Count]; AssetDatabase.RemoveUnusedAssetBundleNames(); // AssetBundleManifest abManifest=new AssetBundleManifest(); //lzma BuildAssetBundleOptions bOption = BuildAssetBundleOptions.None; string currentAssetBundlePath = ""; #if UNITY_IPHONE || UNITY_IOS BuildPipeline.BuildAssetBundles(iosFolder + "/", bOption, BuildTarget.iOS); currentAssetBundlePath = iosFolder; #elif UNITY_ANDROID BuildPipeline.BuildAssetBundles(andriodFolder + "/", bOption, BuildTarget.Android); currentAssetBundlePath = andriodFolder; #endif for (int i = 0; i < sceneAssetBundle.Length; i++) { Hash128 hash; BuildPipeline.GetCRCForAssetBundle(currentAssetBundlePath + "/" + sceneAssetBundle[i], out projectAssetBundlesInfo.sceneAssetBundleCRC[i]); BuildPipeline.GetHashForAssetBundle(currentAssetBundlePath + "/" + sceneAssetBundle[i], out hash); projectAssetBundlesInfo.sceneAssetBundleHash[i] = hash.ToString(); } // TimeSpan tiemSpan = DateTime.Now.ToShortTimeString; projectAssetBundlesInfo.buildTime = DateTime.Today.Year.ToString() + ","; projectAssetBundlesInfo.buildTime += DateTime.Today.Month.ToString() + ","; projectAssetBundlesInfo.buildTime += DateTime.Today.Day.ToString() + ","; projectAssetBundlesInfo.buildTime += DateTime.Now.Hour.ToString() + ","; projectAssetBundlesInfo.buildTime += DateTime.Now.Minute.ToString() + ","; projectAssetBundlesInfo.buildTime += DateTime.Now.Second.ToString(); SaveProjectAssetBundlesInfo(); } // foreach () // { // } }