/// <summary> /// 绘制当前使用的BundleNode的信息 /// </summary> private void DrawBundleNodes() { foreach (var node in m_BundleNodes) { string bundlePath = node.AsDynamic().m_BundlePath; if (!m_BundleNodeFoldoutDic.TryGetValue(bundlePath, out bool isFoldout)) { isFoldout = false; m_BundleNodeFoldoutDic.Add(bundlePath, isFoldout); } bool isDone = node.AsDynamic().IsDone; if (!isDone) { bundlePath += "(Loading)"; } m_BundleNodeFoldoutDic[bundlePath] = EditorGUILayout.Foldout(isFoldout, bundlePath); if (isFoldout) { EditorGUIUtil.BeginGUIBackgroundColor(m_NodeBGColor); { EditorGUILayout.BeginVertical(EditorStyles.helpBox); { EditorGUIUtil.BeginIndent(); { EditorGUILayout.LabelField("Bundle Node:"); EditorGUIUtil.BeginIndent(); { DrawBundleNode(node); } EditorGUIUtil.EndIndent(); if (m_IsShowBundleNodeDirect) { EditorGUILayout.LabelField("Direct Bundle:"); string[] depends = m_AssetBundleManifest.GetDirectDependencies(bundlePath); EditorGUIUtil.BeginIndent(); { foreach (var depend in depends) { BundleNode dependNode = m_BundleNodeDic[depend]; DrawBundleNode(dependNode); EditorGUILayout.Space(); } } EditorGUIUtil.EndIndent(); } } EditorGUIUtil.EndIndent(); } EditorGUILayout.EndVertical(); } EditorGUIUtil.EndGUIBackgroundColor(); } } }
protected override void OnDraw(bool isReadonly, bool isShowDesc) { EditorGUILayout.BeginHorizontal(); { m_IsFoldout = EditorGUILayout.Foldout(m_IsFoldout, m_NameContent, true); OnDrawAskOperation(); } EditorGUILayout.EndHorizontal(); if (m_IsFoldout) { EditorGUIUtil.BeginIndent(); { if (m_ValueObject == null) { EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); { EditorGUILayout.LabelField("Data is null"); if (GUILayout.Button("New", GUILayout.Width(40))) { m_ValueObject = Activator.CreateInstance(m_FieldInfo.FieldType); m_FieldInfo.SetValue(data, m_ValueObject); SetData(data); } } EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.BeginVertical(); { foreach (var fieldData in m_FieldDatas) { if (fieldData.Drawer == null) { EditorGUILayout.LabelField(fieldData.Name, "Drawer is null"); } else { fieldData.Drawer.DrawField(isShowDesc); } } } EditorGUILayout.EndVertical(); } } EditorGUIUtil.EndIndent(); } }
public void OnGUI(bool isShowDesc = false) { bool isNeedIndent = false; if (!string.IsNullOrEmpty(m_Title)) { EditorGUILayout.LabelField(m_Title); isNeedIndent = true; } if (isNeedIndent) { EditorGUIUtil.BeginIndent(); } if (m_Data == null) { EditorGUILayout.HelpBox("Data is null", MessageType.Error); } else { foreach (var fieldData in m_FieldDatas) { if (fieldData.Drawer == null) { EditorGUILayout.LabelField(fieldData.Name, "Drawer is null"); } else { fieldData.Drawer.DrawField(isShowDesc); } } } if (isNeedIndent) { EditorGUIUtil.EndIndent(); } }
/// <summary> /// 绘制AssetNode的详细信息 /// </summary> /// <param name="assetNode">AssetNode数据</param> /// <param name="showMainBundle">是否显示其所在的Bundle</param> /// <param name="showDependBundle">是否显示依赖的Bundle</param> private void DrawAssetNode(AssetNode assetNode, bool showMainBundle = false, bool showDependBundle = false) { dynamic assetNodeDynamic = assetNode.AsDynamic(); string assetPath = assetNodeDynamic.m_AssetPath; bool isDone = assetNodeDynamic.IsDone; bool isAlive = assetNodeDynamic.IsAlive(); int loadCount = assetNodeDynamic.m_LoadCount; List <WeakReference> weakAssets = assetNodeDynamic.m_WeakAssets; EditorGUIUtil.BeginGUIBackgroundColor(m_NodeBGColor); { EditorGUILayout.BeginVertical(EditorStyles.helpBox); { EditorGUIUtil.BeginGUIColor(Color.white); { EditorGUIUtil.BeginIndent(); { EditorGUILayout.LabelField("Asset Node:"); EditorGUIUtil.BeginIndent(); { EditorGUILayout.LabelField($"Asset Path:{assetPath}{(isDone?"":" (Loading)")}"); EditorGUILayout.LabelField($"Is Alive:{isAlive}"); EditorGUILayout.LabelField($"Load Count:{loadCount}"); if (weakAssets.Count > 0) { EditorGUILayout.LabelField("Weak Ref:"); EditorGUIUtil.BeginIndent(); { foreach (var weakRef in weakAssets) { if (!UnityObjectExtension.IsNull(weakRef.Target)) { UnityObject uObj = weakRef.Target as UnityObject; EditorGUILayout.LabelField($"Name:{uObj.name}"); } } } EditorGUIUtil.EndIndent(); } } EditorGUIUtil.EndIndent(); if (showMainBundle || showDependBundle) { BundleNode mainBundleNode = assetNodeDynamic.m_BundleNode; string mainBundlePath = mainBundleNode.AsDynamic().m_BundlePath; EditorGUILayout.LabelField("Bundle Node:"); EditorGUIUtil.BeginIndent(); { if (showMainBundle) { EditorGUILayout.LabelField("Main Bundle:"); EditorGUIUtil.BeginIndent(); { DrawBundleNode(mainBundleNode); } EditorGUIUtil.EndIndent(); } if (showDependBundle) { EditorGUILayout.LabelField("Depend Bundle:"); string[] depends = m_AssetBundleManifest.GetAllDependencies(mainBundlePath); EditorGUIUtil.BeginIndent(); { foreach (var depend in depends) { BundleNode dependNode = m_BundleNodeDic[depend]; DrawBundleNode(dependNode); EditorGUILayout.Space(); } } EditorGUIUtil.EndIndent(); } } EditorGUIUtil.EndIndent(); } } EditorGUIUtil.EndIndent(); } EditorGUIUtil.EndGUIColor(); } EditorGUILayout.EndVertical(); } EditorGUIUtil.EndGUIBackgroundColor(); }
internal void LayoutGUI() { var centeredStyle = new GUIStyle(GUI.skin.GetStyle("Label")); centeredStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label(new GUIContent("Bundle Pack Config"), centeredStyle); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(); { m_PackConfig.OutputDirPath = EditorGUILayoutUtil.DrawDiskFolderSelection("Bundle Output", m_PackConfig.OutputDirPath); if (string.IsNullOrEmpty(m_PackConfig.OutputDirPath)) { m_PackConfig.OutputDirPath = GetDefaultOutputDir(); } m_PackConfig.BuildTarget = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_PackConfig.BuildTarget); m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings"); if (m_AdvancedSettings) { EditorGUIUtil.BeginIndent(); { m_PackConfig.CleanupBeforeBuild = EditorGUILayout.Toggle(m_CleanBeforeBuildContent, m_PackConfig.CleanupBeforeBuild); m_PackConfig.Compression = (CompressOptions)EditorGUILayout.IntPopup(m_CompressionContent, (int)m_PackConfig.Compression, m_CompressionContents, m_CompressionValues); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); { m_IsForceRebuild = EditorGUILayout.Toggle(m_ForceRebuildContent, m_IsForceRebuild); m_IsAppendHash = EditorGUILayout.Toggle(m_AppendHashContent, m_IsAppendHash); } if (EditorGUI.EndChangeCheck()) { if (m_IsForceRebuild) { m_PackConfig.BundleOptions |= BuildAssetBundleOptions.ForceRebuildAssetBundle; } else { m_PackConfig.BundleOptions &= ~BuildAssetBundleOptions.ForceRebuildAssetBundle; } if (m_IsAppendHash) { m_PackConfig.BundleOptions |= BuildAssetBundleOptions.AppendHashToAssetBundleName; } else { m_PackConfig.BundleOptions &= ~BuildAssetBundleOptions.AppendHashToAssetBundleName; } } } EditorGUIUtil.EndIndent(); } EditorGUILayout.Space(); if (GUILayout.Button("Pack Bundle")) { EditorApplication.delayCall += () => { BundlePackUtil.PackAssetBundle(m_PackConfig); }; } } EditorGUILayout.EndVertical(); if (GUI.changed) { Util.FileUtil.SaveToBinary <BundlePackConfig>(BundlePackUtil.GetPackConfigPath(), m_PackConfig); } }