/// <summary> /// 加载所有的音频资源 /// </summary> public static void LoadAudioClipSource() { GenerateAllAudioPatch(); for (int i = 0; i < AudioAssetRelativePathList.Count; i++) { AudioClip cli = AssetDatabase.LoadAssetAtPath <AudioClip>(AudioAssetRelativePathList[i]); if (cli) { string guid = AssetBundleManagerEditor.GetAssetGUIDFromMeta(AudioAssetAbsolutePathList[i]); if (!string.IsNullOrEmpty(guid)) { AudioClipInfo inf = new AudioClipInfo(); inf.AssetGUID = guid; inf.AssetName = GetAssetNameFromPatchWithOutExe(AudioAssetRelativePathList[i]); inf.AssetNameWithExe = GetAssetNameFromPatch(AudioAssetRelativePathList[i]); AssetImporter importer = AssetImporter.GetAtPath(AudioAssetRelativePathList[i]); inf.AssetBundleName = importer.assetBundleName; if (!string.IsNullOrEmpty(importer.assetBundleVariant)) { inf.AssetBundleName += "." + importer.assetBundleVariant; } inf.AudioLength = cli.length; inf.ResObj = cli; inf.AbsolutePatch = AudioAssetAbsolutePathList[i]; inf.RelativePatch = AudioAssetRelativePathList[i]; inf.HostTreeViewName = string.Empty; AudioSourceList.Add(inf); AudioSourceTable.Add(guid, inf); } } } GenrateResTreeView(); }
public static AssetBundleManagerEditor.AssetBundleEditorInfo MakeSchemeAssetBundleInfo(string patch) { AssetBundleManagerEditor.AssetBundleEditorInfo info = null; AssetImporter assetImporter = AssetImporter.GetAtPath(patch); if (!assetImporter) { return(info); } string asPatch = assetImporter.assetPath; //不是在这个路径下的,不是场景文件,不处理 if (!isSchemeAssets(asPatch)) { return(info); } //移除头部 asPatch = asPatch.Replace(SchemePatch, ""); string[] strs = asPatch.Split('/'); //没有放到其他文件夹下,则使用默认的包 if (strs.Length <= 1) { asPatch = "Default"; } else { //移除名字 asPatch = asPatch.Replace(strs[strs.Length - 1], ""); //再移除最后的斜杠 asPatch = asPatch.Remove(asPatch.Length - 1); } string assetName = Path.GetFileNameWithoutExtension(assetImporter.assetPath); string guid = AssetBundleManagerEditor.GetAssetGUIDFromMeta(assetImporter.assetPath); if (guid.Equals(string.Empty)) { return(info); } //最后就是包名 string abName = AssetBundleManager.SchemeVariant + "/" + asPatch; string variant = AssetBundleManager.SchemeVariant; SaveAssetBundleData(assetImporter, abName, variant); info = new AssetBundleManagerEditor.AssetBundleEditorInfo(); info.AssetBundleName = abName; info.AssetBundleVarian = variant; info.guid = guid; info.assetName = assetName; DispatchScheme(patch); return(info); }
public static AssetBundleManagerEditor.AssetBundleEditorInfo MakePrefabAssetBundleInfo(string patch) { AssetBundleManagerEditor.AssetBundleEditorInfo info = null; string lowerPatch = patch; if (!IsPrefabAssets(lowerPatch)) { return(info); } AssetImporter assetImporter = AssetImporter.GetAtPath(patch); if (!assetImporter) { return(info); } string asPatch = assetImporter.assetPath; //移除头部 asPatch = asPatch.Replace(PrefabPatch, ""); asPatch = asPatch.Replace(ArtitsPatch, ""); string[] strs = asPatch.Split('/'); //没有放到其他文件夹下,则使用默认的包 if (strs.Length <= 1) { asPatch = "Default"; } else { //移除名字 asPatch = asPatch.Replace(strs[strs.Length - 1], ""); //再移除最后的斜杠 asPatch = asPatch.Remove(asPatch.Length - 1); } string assetName = Path.GetFileNameWithoutExtension(assetImporter.assetPath); string guid = AssetBundleManagerEditor.GetAssetGUIDFromMeta(assetImporter.assetPath); if (guid.Equals(string.Empty)) { return(info); } string abName = "gameobject/" + asPatch + "/" + assetName; string variant = AssetBundleManager.PrefabVariant; SaveAssetBundleData(assetImporter, abName, variant); info = new AssetBundleManagerEditor.AssetBundleEditorInfo(); info.AssetBundleName = abName; info.AssetBundleVarian = variant; info.guid = guid; info.assetName = assetName; return(info); }
public static string GetGUID(string assetPath) { string ablotePatch = Application.dataPath; ablotePatch = ablotePatch.Replace("Assets", ""); ablotePatch += assetPath; return(AssetBundleManagerEditor.GetAssetGUIDFromMeta(ablotePatch)); }
public static ResConfigData BuildResConfigData(string path, string referenceAssetbundleName, string referenceVariant) { if (!referenceAssetbundleName.Equals(string.Empty) && !referenceVariant.Equals(string.Empty)) { string guid = AssetBundleManagerEditor.GetAssetGUIDFromMeta(path); string assetName = Path.GetFileNameWithoutExtension(path); ResConfigData cof = new ResConfigData(); cof.AssetBundleName = referenceAssetbundleName + "." + referenceVariant; cof.AssetGUID = guid; cof.AssetName = assetName; return(cof); } return(null); }
private static AssetBundleManagerEditor.AssetBundleEditorInfo MakeSceneAssetBundleInfo(string patch) { AssetBundleManagerEditor.AssetBundleEditorInfo info = null; AssetImporter assetImporter = AssetImporter.GetAtPath(patch); if (!assetImporter) { return(info); } string asPatch = assetImporter.assetPath; //不是在这个路径下的,不是场景文件,不处理 if (!isSceneAssets(asPatch)) { return(info); } //场景文件是一个文件一个包,所以去掉头,然后去调后缀名就是包了 //移除头部 asPatch = asPatch.Replace(scenePatch, ""); //就去掉后缀名 asPatch = asPatch.Replace(".unity", ""); string abName = "Scene/" + asPatch; string variant = AssetBundleManager.sceneVariant; string guid = AssetBundleManagerEditor.GetAssetGUIDFromMeta(assetImporter.assetPath); if (guid.Equals(string.Empty)) { return(info); } string assetName = Path.GetFileNameWithoutExtension(assetImporter.assetPath); SaveAssetBundleData(assetImporter, abName, variant); info = new AssetBundleManagerEditor.AssetBundleEditorInfo(); info.AssetBundleName = abName; info.AssetBundleVarian = variant; info.guid = guid; info.assetName = assetName; return(info); }
// 默认的成员编辑 public void DefaultMemberEdit(MemberInfo info) { SerializedProperty prop = serializedObject.FindProperty(info.Name); if (prop == null) { return; } // 显示名字 EditorGUILayout.BeginVertical(editorInstance.rootGroupStyle); { EditorGUILayout.BeginHorizontal(); { // 根据info.Name和prop.type自己选择不同的编辑方式 if (prop.type != "") { //AssetBundleName和AssetName不可编辑 if (info.Name.Equals("AssetGUID")) { GUI.enabled = false; } EditorGUILayout.PropertyField(prop, true); GUI.enabled = true; //拖拽预制体的时候,同时赋值三个信息 if (info.Name.Equals("effectPrefb") && prop.objectReferenceValue) { AssetImporter asp = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(prop.objectReferenceValue)); SerializedProperty AssetGUID_prop = serializedObject.FindProperty("AssetGUID"); if (asp && null != AssetGUID_prop) { AssetGUID_prop.stringValue = AssetBundleManagerEditor.GetAssetGUIDFromMeta(asp.assetPath); //prop.objectReferenceValue = null; } else { Debug.LogError("获取资源信息失败!"); } } serializedObject.ApplyModifiedProperties(); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { bool bMovedSound = false; bool bImportSound = false; //处理的是否是UI文件 bool bImportUI = false; OnPreProcessScheme(); for (int i = 0; i < importedAssets.Length; i++) { //看看是不是场景文件 string s = importedAssets[i]; AssetBundleManagerEditor.CheckAssetName(s); if (isSceneAssets(s)) { MakeSceneAssetBundleInfo(s); } else if (isShaderAssets(s)) { MakeShaderAssetBundle(s); } else if (isMeshAssets(s)) { MakeMeshAssetBundle(s); } else if (isAudioAssets(s)) { bImportSound = true; MakeSoundAssetBundleData(s); } else if (IsFontAsset(s)) { MakeFontBundleData(AssetImporter.GetAtPath(s)); } else if (IsFBXAsset(s)) { MakeFBXAssetBundle(AssetImporter.GetAtPath(s) as ModelImporter); } else if (IsMaterialAsset(s)) { MakeMaterialAssetBundle(s); } else if (IsAniClipAsset(s)) { MakeAnimatorClipAssetBundleData(s); } else if (IsControllerAsset(s)) { MakeAnimatorControllerAssetBundleData(s); } else if (IsTextureAsset(s)) { MakeTextureAssetBundle(s); } else if (isSchemeAssets(s)) { MakeSchemeAssetBundleInfo(s); } string path = importedAssets[i]; //载入的话弄到表里 if (path.Contains(UIDynamicAssetPatch)) { if (!IsTextureAsset(path)) { continue; } bImportUI = true; UFileData data = new UFileData(); data.configData = MakeTextureAssetBundleFromReference(path, string.Empty); if (null != data.configData) { PostprocessUITextureToCSV.nEditorInstance.InsetConfig(data); } else { Debug.LogError("取得UI资源失败:" + path); } } } //资源移动了 List <string> movedGUID = new List <string>(); for (int i = 0; i < movedAssets.Length; i++) { string str = movedAssets[i]; AssetBundleManagerEditor.CheckAssetName(movedAssets[i]); //先清掉ab ClearAssetBundleData(AssetImporter.GetAtPath(str)); //再根据资源类型来重新生成ab //是音效的 if (isAudioAssets(str)) { MakeSoundAssetBundleData(str); movedGUID.Add(AssetBundleManagerEditor.GetAssetGUIDFromMeta(str)); bMovedSound = true; } //是贴图 else if (IsTextureAsset(str)) { MakeTextureAssetBundle(str); } //是场景 else if (isSceneAssets(str)) { MakeSceneAssetBundleInfo(str); } else if (IsFontAsset(str)) { MakeFontBundleData(AssetImporter.GetAtPath(str)); } else if (IsFBXAsset(str)) { CheckFBXInImportTime(str); MakeFBXAssetBundle(AssetImporter.GetAtPath(str) as ModelImporter); } else if (IsMaterialAsset(str)) { MakeMaterialAssetBundle(str); } else if (IsAniClipAsset(str)) { MakeAnimatorClipAssetBundleData(str); } else if (IsControllerAsset(str)) { MakeAnimatorControllerAssetBundleData(str); } else if (isSchemeAssets(str)) { MakeSchemeAssetBundleInfo(str); } else if (isShaderAssets(str)) { MakeShaderAssetBundle(str); } else if (isMeshAssets(str)) { MakeMeshAssetBundle(str); } string path = movedAssets[i]; if (path.Contains(UIDynamicAssetPatch)) { bImportUI = true; AssetImporter assetImporter = AssetImporter.GetAtPath(path); PostprocessUITextureToCSV.nEditorInstance.RemoveConfig(PostprocessUITextureToCSV.GetGUID(assetImporter.assetPath)); } } if (SoundSystem.SoundSystemEditorWindow.EditorInstance) { if (bMovedSound || bImportSound) { if (bMovedSound) { SoundSystem.SoundSystemEditorWindow.RefrshAudioClipSource(movedGUID); } else { SoundSystem.SoundSystemEditorWindow.RefrshAudioClipSource(); } } } //UI的处理完保存配置 if (bImportUI) { PostprocessUITextureToCSV.nEditorInstance.ExportConfig(); } OnPostProcessScheme(); if (!AssetBundleManagerEditor.isBuildingPackage && !AssetBundleManagerEditor.isCleaningAssets) { AssetBundleManager.LoadPrefabConfig(); for (int i = 0; i < movedAssets.Length; i++) { string str = movedAssets[i]; if (IsPrefabAssets(movedFromAssetPaths[i])) { ClearSinglePrefab(str); } if (IsPrefabAssets(str)) { ImportSinglePrefab(str, true); } } for (int i = 0; i < importedAssets.Length; i++) { ImportSinglePrefab(importedAssets[i], true); } SchemeExport.Export_PrefabScheme(); AssetBundleManager.ClearPrefabConfig(); } //进入播放模式的时候会调用一次这个postallasets,所以要加载一次配置 if (Application.isPlaying) { AssetBundleManager.LoadPrefabConfig(); } if (movedAssets.Length > 0) { AssetDatabase.Refresh(); } //移除无用的ab名 AssetDatabase.RemoveUnusedAssetBundleNames(); }
/// <summary> /// 绘制配置信息 /// </summary> private void DrawConfigInfo() { Rect pos = position; AudioConfigInfoRect.x = ConfigViewListRect.width; AudioConfigInfoRect.y = 0; AudioConfigInfoRect.width = pos.width - ConfigViewListRect.width - AudioResourceListRect.width; AudioConfigInfoRect.height = AudioResourceListRect.height * 0.67f; GUI.Box(AudioConfigInfoRect, ""); GUILayout.BeginArea(AudioConfigInfoRect); ConfigInofScrollViewPos = GUILayout.BeginScrollView(ConfigInofScrollViewPos, GUILayout.Height(AudioConfigInfoRect.height)); GUILayout.BeginVertical("box"); if (currentSelectedConfig == null) { GUILayout.Label("无可用配置信息.."); } else { GUILayout.Label("配置信息:"); GUILayout.BeginHorizontal("box"); currentSelectedConfig.data.nID = EditorGUILayout.IntField("ID:", currentSelectedConfig.data.nID); GUILayout.EndHorizontal(); currentSelectedConfig.data.soundType = (EMSoundType)EditorGUILayout.EnumPopup("声音类型:", currentSelectedConfig.data.soundType); currentSelectedConfig.data.mixerGroupType = (AudioMixerGroupType)EditorGUILayout.EnumPopup("混音组类型:", currentSelectedConfig.data.mixerGroupType); currentSelectedConfig.data.nMixerGroupIndex = EditorGUILayout.IntField("混音组序号:", currentSelectedConfig.data.nMixerGroupIndex); GUI.changed = false; currentSelectedConfig.data.bBypassEffect = EditorGUILayout.Toggle("Bypass Effects:", currentSelectedConfig.data.bBypassEffect); currentSelectedConfig.data.bBypassReverbZone = EditorGUILayout.Toggle("Bypass Reverb Zone:", currentSelectedConfig.data.bBypassReverbZone); currentSelectedConfig.data.bPlayOnAwake = EditorGUILayout.Toggle("Play On Awake:", currentSelectedConfig.data.bPlayOnAwake); currentSelectedConfig.data.nPriority = EditorGUILayout.IntField("Priority:", currentSelectedConfig.data.nPriority); currentSelectedConfig.data.fPitch = EditorGUILayout.FloatField("Pitch:", currentSelectedConfig.data.fPitch); currentSelectedConfig.data.fStereoPan = EditorGUILayout.FloatField("Stereo Pan:", currentSelectedConfig.data.fStereoPan); currentSelectedConfig.data.fReverZoneMix = EditorGUILayout.FloatField("Rever Zone Mix:", currentSelectedConfig.data.fReverZoneMix); currentSelectedConfig.data.b3DSound = EditorGUILayout.Toggle("是否3D音效:", currentSelectedConfig.data.b3DSound); if (currentSelectedConfig.data.b3DSound) { currentSelectedConfig.data.fDopplerLv = EditorGUILayout.FloatField("Doppler Level:", currentSelectedConfig.data.fDopplerLv); currentSelectedConfig.data.nSpread = EditorGUILayout.IntField("Spread:", currentSelectedConfig.data.nSpread); currentSelectedConfig.data.audioRoffType = (AudioRolloffMode)EditorGUILayout.EnumPopup("Volume Rolloff:", currentSelectedConfig.data.audioRoffType); currentSelectedConfig.data.fMinDistance = EditorGUILayout.FloatField("Min Distance:", currentSelectedConfig.data.fMinDistance); currentSelectedConfig.data.fMaxDistance = EditorGUILayout.FloatField("Max Distance:", currentSelectedConfig.data.fMaxDistance); } currentSelectedConfig.data.nPlayTimes = EditorGUILayout.IntField("播放次数(≤0循环):", currentSelectedConfig.data.nPlayTimes); currentSelectedConfig.data.fDuartion = EditorGUILayout.FloatField("持续时间(≤0无限):", currentSelectedConfig.data.fDuartion); currentSelectedConfig.data.fDelayPlayTime = EditorGUILayout.FloatField("延迟时间(≤0.03无延迟):", currentSelectedConfig.data.fDelayPlayTime); currentSelectedConfig.data.fIntervalBetweenPlayTimes = EditorGUILayout.FloatField("两次之间播放间隔(≤0无间隔):", currentSelectedConfig.data.fIntervalBetweenPlayTimes); if (GUI.changed) { // CurrentSoundConfigTable[currentSelectedConfig.data.nID] = currentSelectedConfig; } GUILayout.BeginVertical("box"); GUILayout.Label("依赖预制体:"); currentSelectedConfig.data.dependAsset = (GameObject)EditorGUILayout.ObjectField(currentSelectedConfig.data.dependAsset, typeof(Object), true); GUILayout.EndVertical(); AssetImporter asp = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(currentSelectedConfig.data.dependAsset)); if (asp) { string szGUID = AssetBundleManagerEditor.GetAssetGUIDFromMeta(asp.assetPath); if (currentSelectedConfig.data.szDependAssetGUID == string.Empty || (currentSelectedConfig.data.szDependAssetGUID != string.Empty && szGUID != string.Empty)) { currentSelectedConfig.data.szDependAssetGUID = szGUID; } } GUI.enabled = false; currentSelectedConfig.data.szDependAssetGUID = EditorGUILayout.TextField("资源所在的资源包:", currentSelectedConfig.data.szDependAssetGUID); GUI.enabled = true; GUILayout.Space(5.0f); GUILayout.BeginVertical("box"); GUILayout.Label("资源所在的资源包:" + currentSelectedConfig.data.AssetBundleName); GUILayout.Label("资源名:" + currentSelectedConfig.data.AssetName); GUILayout.Label("资源GUID:" + currentSelectedConfig.data.AssetGUID); GUILayout.EndVertical(); } GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndArea(); }
private static AssetBundleManagerEditor.AssetBundleEditorInfo MakeSoundAssetBundleData(string path) { AssetBundleManagerEditor.AssetBundleEditorInfo info = null; AssetImporter importer = AssetImporter.GetAtPath(path); if (!importer) { return(info); } AudioImporter assetImporter = importer as AudioImporter; if (!assetImporter) { return(info); } string asPatch = assetImporter.assetPath; //不是在这个路径下的,不处理 if (!isAudioAssets(asPatch)) { return(info); } //移除头部 asPatch = asPatch.Replace(soundAssetPatch, ""); string[] strs = asPatch.Split('/'); //没有放到其他文件夹下,则使用默认的音效包名 if (strs.Length <= 1) { asPatch = "DefaultSound"; } else { //移除名字 asPatch = asPatch.Replace(strs[strs.Length - 1], ""); //再移除最后的斜杠 asPatch = asPatch.Remove(asPatch.Length - 1); } string assetName = Path.GetFileNameWithoutExtension(assetImporter.assetPath); string guid = AssetBundleManagerEditor.GetAssetGUIDFromMeta(assetImporter.assetPath); if (guid.Equals(string.Empty)) { return(info); } string abName = "Sound/" + asPatch; string variant = AssetBundleManager.soundVariant; SaveAssetBundleData(assetImporter, abName, variant); info = new AssetBundleManagerEditor.AssetBundleEditorInfo(); info.AssetBundleName = abName; info.AssetBundleVarian = variant; info.guid = guid; info.assetName = assetName; return(info); }
private static AssetBundleManagerEditor.AssetBundleEditorInfo BuildAnimatorControllerAssetBundleInfo(AssetImporter assetImporter, string referenceAssetbundleName) { string AbName = string.Empty; string AbVirtant = string.Empty; if (!assetImporter) { return(null); } if (!CheckAssetDependices(assetImporter.assetPath)) { return(null); } string asPatch = assetImporter.assetPath; if (!IsControllerAsset(asPatch)) { return(null); } //区分一下是模型还是特效 string patchHead = string.Empty; if (asPatch.Contains(ModelAnimatorControllerPatch)) { patchHead = "model/"; } //移除头部 asPatch = asPatch.Replace(ModelAnimatorControllerPatch, ""); asPatch = asPatch.Replace(ArtitsPatch, ""); string[] strs = asPatch.Split('/'); //没有放到其他文件夹下,则使用默认的包 if (strs.Length <= 1) { asPatch = "Default"; } else { //移除名字 asPatch = asPatch.Replace(strs[strs.Length - 1], ""); //再移除最后的斜杠 asPatch = asPatch.Remove(asPatch.Length - 1); } AbName = "animcontroller/" + patchHead + asPatch; AbVirtant = AssetBundleManager.AnimatorControllerVariant; string assetName = Path.GetFileNameWithoutExtension(assetImporter.assetPath); string assetGUID = AssetBundleManagerEditor.GetAssetGUIDFromMeta(assetImporter.assetPath); if (assetName.Equals(string.Empty) || assetGUID.Equals(string.Empty)) { return(null); } if (!referenceAssetbundleName.Equals(string.Empty)) { AbName = referenceAssetbundleName; } AssetBundleManagerEditor.AssetBundleEditorInfo info = new AssetBundleManagerEditor.AssetBundleEditorInfo(); info.AssetBundleName = AbName; info.AssetBundleVarian = AbVirtant; info.guid = assetGUID; info.assetName = assetName; return(info); }
private static AssetBundleManagerEditor.AssetBundleEditorInfo BuildMaterialAssetBundleInfo(AssetImporter assetImporter, string referenceAssetbundleName) { string AbName = string.Empty; string AbVirtant = string.Empty; if (!assetImporter) { return(null); } if (!CheckAssetDependices(assetImporter.assetPath)) { return(null); } string asPatch = assetImporter.assetPath; if (!IsMaterialAsset(asPatch)) { return(null); } //移除头部 asPatch = asPatch.Replace(ArtitsPatch, ""); string[] strs = asPatch.Split('/'); //没有放到其他文件夹下,则使用默认的包 if (strs.Length <= 1) { asPatch = "Default"; } else { //移除名字 asPatch = asPatch.Replace(strs[strs.Length - 1], ""); //再移除最后的斜杠 asPatch = asPatch.Remove(asPatch.Length - 1); } //最后就是包名 AbName = "Material/" + asPatch; AbVirtant = AssetBundleManager.MatVariant; if (AbName.Equals(string.Empty) || AbVirtant.Equals(string.Empty)) { return(null); } string assetName = Path.GetFileNameWithoutExtension(assetImporter.assetPath); string assetGUID = AssetBundleManagerEditor.GetAssetGUIDFromMeta(assetImporter.assetPath); if (assetName.Equals(string.Empty) || assetGUID.Equals(string.Empty)) { return(null); } if (!referenceAssetbundleName.Equals(string.Empty)) { AbName = referenceAssetbundleName; } AssetBundleManagerEditor.AssetBundleEditorInfo info = new AssetBundleManagerEditor.AssetBundleEditorInfo(); info.AssetBundleName = AbName; info.AssetBundleVarian = AbVirtant; info.guid = assetGUID; info.assetName = assetName; return(info); }
private static AssetBundleManagerEditor.AssetBundleEditorInfo BuildAnimatorClipAssetBundleInfo(AssetImporter assetImporter, string referenceAssetbundleName) { string AbName = string.Empty; string AbVirtant = string.Empty; if (!assetImporter) { return(null); } string asPatch = assetImporter.assetPath; //移除头部 asPatch = asPatch.Replace(ArtitsPatch, ""); string[] strs = asPatch.Split('/'); //没有放到其他文件夹下,则使用默认的包 if (strs.Length <= 1) { asPatch = "Default"; } else { //移除名字 asPatch = asPatch.Replace(strs[strs.Length - 1], ""); //再移除最后的斜杠 asPatch = asPatch.Remove(asPatch.Length - 1); } //最后就是包名 AbName = "animclip/" + asPatch; AbVirtant = AssetBundleManager.AnimatorClipVariant; string assetName = Path.GetFileNameWithoutExtension(assetImporter.assetPath); string assetGUID = AssetBundleManagerEditor.GetAssetGUIDFromMeta(assetImporter.assetPath); if (assetName.Equals(string.Empty) || assetGUID.Equals(string.Empty)) { return(null); } if (!referenceAssetbundleName.Equals(string.Empty)) { AbName = referenceAssetbundleName; } AssetBundleManagerEditor.AssetBundleEditorInfo info = new AssetBundleManagerEditor.AssetBundleEditorInfo(); info.AssetBundleName = AbName; info.AssetBundleVarian = AbVirtant; info.guid = assetGUID; info.assetName = assetName; AssetBundleManagerEditor.AssetFileInfo fileInfo = AssetBundleManagerEditor.GetFileInfo(AssetBundleManagerEditor.ConverRelativePatchToObslotePatch(assetImporter.assetPath)); if (fileInfo != null) { info.Asset_X = fileInfo.fileLengthInMB; info.Asset_Y = fileInfo.fileLengthInMB; } return(info); }
private static AssetBundleManagerEditor.AssetBundleEditorInfo BuildTextureAssetBundleInfo(AssetImporter assetImporter, string referenceAssetbundleName) { string AbName = string.Empty; string AbVirtant = string.Empty; string asPatch = assetImporter.assetPath; bool isSprite = IsSpriteAssets(asPatch); bool isHaveSpritePacking = false; if (isSprite) { TextureImporter tp = assetImporter as TextureImporter; isHaveSpritePacking = IsHaveSpritePacking(tp); if (isHaveSpritePacking) { BuildTextureAssetBundleName_SpritePacking(tp.spritePackingTag, out AbName, out AbVirtant, true); } else { BuildTextureAssetBundleName_Normal(asPatch, out AbName, out AbVirtant, true, referenceAssetbundleName); } } else { BuildTextureAssetBundleName_Normal(asPatch, out AbName, out AbVirtant, false, referenceAssetbundleName); } if (AbName.Equals(string.Empty) || AbVirtant.Equals(string.Empty)) { return(null); } string assetName = Path.GetFileNameWithoutExtension(asPatch); string assetGUID = AssetBundleManagerEditor.GetAssetGUIDFromMeta(asPatch); if (assetName.Equals(string.Empty) || assetGUID.Equals(string.Empty)) { return(null); } AssetBundleManagerEditor.AssetBundleEditorInfo info = new AssetBundleManagerEditor.AssetBundleEditorInfo(); info.AssetBundleName = AbName; info.AssetBundleVarian = AbVirtant; info.guid = assetGUID; info.assetName = assetName; info.Asset_X = -1; info.Asset_Y = -1; if (!isHaveSpritePacking) { int w, h; if (!GetTextureInfo(assetImporter, out w, out h)) { Debug.LogWarning("贴图信息读取失败,请重新导入资源:" + assetImporter.assetPath); info.Asset_X = 2048; info.Asset_Y = 2048; } else { info.Asset_X = w; info.Asset_Y = h; } } else { //info.Asset_X = 3535;//特殊含义,表示这个贴图有图集,因为图集会分多个group,在加载之前是不知道属于哪一个group的 //info.Asset_Y = 5353; info.Asset_X = 2048; info.Asset_Y = 2048; } return(info); }
public override void OnMemberGUI(MemberInfo info) { //获取中文Name string itemDesc = info.Name; var nameObj = info.GetCustomAttributes(typeof(DescAttribute), true); if (nameObj.Length > 0) { itemDesc = ((DescAttribute)nameObj[0]).description; } ////获取中文ToolTip //string itemTooltip = ""; //var tooltipObj = info.GetCustomAttributes(typeof(TooltipAttribute), true); //if (tooltipObj.Length > 0) //{ // itemTooltip = ((TooltipAttribute)tooltipObj[0]).tooltip; //} SerializedProperty prop = serializedObject.FindProperty(info.Name); if (prop == null) { return; } if (info.Name.Equals("NeedCache")) { SerializedProperty eVocationProp = serializedObject.FindProperty("eVocation"); if (!eVocationProp.enumNames[eVocationProp.enumValueIndex].Equals(VOCATION.VOCATION_INVALID.ToString())) { return; } } // 显示名字 EditorGUILayout.BeginVertical(editorInstance.rootGroupStyle); { if (itemDesc != "") { EditorGUILayout.LabelField(itemDesc + " : "); } EditorGUILayout.BeginHorizontal(); { // 根据info.Name和prop.type自己选择不同的编辑方式 if (prop.type != "") { //AssetBundleName和AssetName不可编辑 if (info.Name.Equals("AssetGUID")) { GUI.enabled = false; } GUIContent descContent = new GUIContent(info.Name + ":", itemDesc); EditorGUIUtility.labelWidth = 500; EditorGUILayout.PropertyField(prop, descContent, true); //EditorGUILayout.LabelField(itemTooltip); GUI.enabled = true; //拖拽预制体的时候,同时赋值三个信息 if (info.Name.Equals("effectPrefb") && prop.objectReferenceValue) { AssetImporter asp = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(prop.objectReferenceValue)); SerializedProperty AssetGUID_prop = serializedObject.FindProperty("AssetGUID"); if (asp && null != AssetGUID_prop) { AssetGUID_prop.stringValue = AssetBundleManagerEditor.GetAssetGUIDFromMeta(asp.assetPath); //prop.objectReferenceValue = null; } else { Debug.LogError("获取资源信息失败!"); } } serializedObject.ApplyModifiedProperties(); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); }