public override void OnInspectorGUI() { base.OnInspectorGUI(); serializedObject.Update(); ResourceComponent t = (ResourceComponent)target; bool isEditorResourceMode = (bool)m_EditorResourceModeFieldInfo.GetValue(target); if (isEditorResourceMode) { EditorGUILayout.HelpBox("Editor resource mode is enabled. Some options are disabled.", MessageType.Warning); } EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode); { if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject)) { EditorGUILayout.EnumPopup("Resource Mode", t.ResourceMode); } else { int selectedIndex = EditorGUILayout.Popup("Resource Mode", m_ResourceModeIndex, ResourceModeNames); if (selectedIndex != m_ResourceModeIndex) { m_ResourceModeIndex = selectedIndex; m_ResourceMode.enumValueIndex = selectedIndex + 1; } } m_ReadWritePathType.enumValueIndex = (int)(ReadWritePathType)EditorGUILayout.EnumPopup("Read Write Path Type", t.ReadWritePathType); } EditorGUI.EndDisabledGroup(); float unloadUnusedAssetsInterval = EditorGUILayout.Slider("Unload Unused Assets Interval", m_UnloadUnusedAssetsInterval.floatValue, 0f, 3600f); if (unloadUnusedAssetsInterval != m_UnloadUnusedAssetsInterval.floatValue) { if (EditorApplication.isPlaying) { t.UnloadUnusedAssetsInterval = unloadUnusedAssetsInterval; } else { m_UnloadUnusedAssetsInterval.floatValue = unloadUnusedAssetsInterval; } } EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying && isEditorResourceMode); { float assetAutoReleaseInterval = EditorGUILayout.DelayedFloatField("Asset Auto Release Interval", m_AssetAutoReleaseInterval.floatValue); if (assetAutoReleaseInterval != m_AssetAutoReleaseInterval.floatValue) { if (EditorApplication.isPlaying) { t.AssetAutoReleaseInterval = assetAutoReleaseInterval; } else { m_AssetAutoReleaseInterval.floatValue = assetAutoReleaseInterval; } } int assetCapacity = EditorGUILayout.DelayedIntField("Asset Capacity", m_AssetCapacity.intValue); if (assetCapacity != m_AssetCapacity.intValue) { if (EditorApplication.isPlaying) { t.AssetCapacity = assetCapacity; } else { m_AssetCapacity.intValue = assetCapacity; } } float assetExpireTime = EditorGUILayout.DelayedFloatField("Asset Expire Time", m_AssetExpireTime.floatValue); if (assetExpireTime != m_AssetExpireTime.floatValue) { if (EditorApplication.isPlaying) { t.AssetExpireTime = assetExpireTime; } else { m_AssetExpireTime.floatValue = assetExpireTime; } } int assetPriority = EditorGUILayout.DelayedIntField("Asset Priority", m_AssetPriority.intValue); if (assetPriority != m_AssetPriority.intValue) { if (EditorApplication.isPlaying) { t.AssetPriority = assetPriority; } else { m_AssetPriority.intValue = assetPriority; } } float resourceAutoReleaseInterval = EditorGUILayout.DelayedFloatField("Resource Auto Release Interval", m_ResourceAutoReleaseInterval.floatValue); if (resourceAutoReleaseInterval != m_ResourceAutoReleaseInterval.floatValue) { if (EditorApplication.isPlaying) { t.ResourceAutoReleaseInterval = resourceAutoReleaseInterval; } else { m_ResourceAutoReleaseInterval.floatValue = resourceAutoReleaseInterval; } } int resourceCapacity = EditorGUILayout.DelayedIntField("Resource Capacity", m_ResourceCapacity.intValue); if (resourceCapacity != m_ResourceCapacity.intValue) { if (EditorApplication.isPlaying) { t.ResourceCapacity = resourceCapacity; } else { m_ResourceCapacity.intValue = resourceCapacity; } } float resourceExpireTime = EditorGUILayout.DelayedFloatField("Resource Expire Time", m_ResourceExpireTime.floatValue); if (resourceExpireTime != m_ResourceExpireTime.floatValue) { if (EditorApplication.isPlaying) { t.ResourceExpireTime = resourceExpireTime; } else { m_ResourceExpireTime.floatValue = resourceExpireTime; } } int resourcePriority = EditorGUILayout.DelayedIntField("Resource Priority", m_ResourcePriority.intValue); if (resourcePriority != m_ResourcePriority.intValue) { if (EditorApplication.isPlaying) { t.ResourcePriority = resourcePriority; } else { m_ResourcePriority.intValue = resourcePriority; } } if (m_ResourceModeIndex > 0) { string updatePrefixUri = EditorGUILayout.DelayedTextField("Update Prefix Uri", m_UpdatePrefixUri.stringValue); if (updatePrefixUri != m_UpdatePrefixUri.stringValue) { if (EditorApplication.isPlaying) { t.UpdatePrefixUri = updatePrefixUri; } else { m_UpdatePrefixUri.stringValue = updatePrefixUri; } } int generateReadWriteVersionListLength = EditorGUILayout.DelayedIntField("Generate Read Write Version List Length", m_GenerateReadWriteVersionListLength.intValue); if (generateReadWriteVersionListLength != m_GenerateReadWriteVersionListLength.intValue) { if (EditorApplication.isPlaying) { t.GenerateReadWriteVersionListLength = generateReadWriteVersionListLength; } else { m_GenerateReadWriteVersionListLength.intValue = generateReadWriteVersionListLength; } } int updateRetryCount = EditorGUILayout.DelayedIntField("Update Retry Count", m_UpdateRetryCount.intValue); if (updateRetryCount != m_UpdateRetryCount.intValue) { if (EditorApplication.isPlaying) { t.UpdateRetryCount = updateRetryCount; } else { m_UpdateRetryCount.intValue = updateRetryCount; } } } } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode); { EditorGUILayout.PropertyField(m_InstanceRoot); m_ResourceHelperInfo.Draw(); m_LoadResourceAgentHelperInfo.Draw(); m_LoadResourceAgentHelperCount.intValue = EditorGUILayout.IntSlider("Load Resource Agent Helper Count", m_LoadResourceAgentHelperCount.intValue, 1, 128); } EditorGUI.EndDisabledGroup(); if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject)) { EditorGUILayout.LabelField("Read Only Path", t.ReadOnlyPath.ToString()); EditorGUILayout.LabelField("Read Write Path", t.ReadWritePath.ToString()); EditorGUILayout.LabelField("Current Variant", t.CurrentVariant ?? "<Unknwon>"); EditorGUILayout.LabelField("Applicable Game Version", isEditorResourceMode ? "N/A" : t.ApplicableGameVersion ?? "<Unknwon>"); EditorGUILayout.LabelField("Internal Resource Version", isEditorResourceMode ? "N/A" : t.InternalResourceVersion.ToString()); EditorGUILayout.LabelField("Asset Count", isEditorResourceMode ? "N/A" : t.AssetCount.ToString()); EditorGUILayout.LabelField("Resource Count", isEditorResourceMode ? "N/A" : t.ResourceCount.ToString()); EditorGUILayout.LabelField("Resource Group Count", isEditorResourceMode ? "N/A" : t.ResourceGroupCount.ToString()); if (m_ResourceModeIndex > 0) { EditorGUILayout.LabelField("Applying Resource Pack Path", isEditorResourceMode ? "N/A" : t.ApplyingResourcePackPath ?? "<Unknwon>"); EditorGUILayout.LabelField("Apply Waiting Count", isEditorResourceMode ? "N/A" : t.ApplyWaitingCount.ToString()); EditorGUILayout.LabelField("Updating Resource Group", isEditorResourceMode ? "N/A" : t.UpdatingResourceGroup != null ? t.UpdatingResourceGroup.Name : "<Unknwon>"); EditorGUILayout.LabelField("Update Waiting Count", isEditorResourceMode ? "N/A" : t.UpdateWaitingCount.ToString()); EditorGUILayout.LabelField("Update Candidate Count", isEditorResourceMode ? "N/A" : t.UpdateCandidateCount.ToString()); EditorGUILayout.LabelField("Updating Count", isEditorResourceMode ? "N/A" : t.UpdatingCount.ToString()); } EditorGUILayout.LabelField("Load Total Agent Count", isEditorResourceMode ? "N/A" : t.LoadTotalAgentCount.ToString()); EditorGUILayout.LabelField("Load Free Agent Count", isEditorResourceMode ? "N/A" : t.LoadFreeAgentCount.ToString()); EditorGUILayout.LabelField("Load Working Agent Count", isEditorResourceMode ? "N/A" : t.LoadWorkingAgentCount.ToString()); EditorGUILayout.LabelField("Load Waiting Task Count", isEditorResourceMode ? "N/A" : t.LoadWaitingTaskCount.ToString()); if (!isEditorResourceMode) { EditorGUILayout.BeginVertical("box"); { TaskInfo[] loadAssetInfos = t.GetAllLoadAssetInfos(); if (loadAssetInfos.Length > 0) { foreach (TaskInfo loadAssetInfo in loadAssetInfos) { DrawLoadAssetInfo(loadAssetInfo); } if (GUILayout.Button("Export CSV Data")) { string exportFileName = EditorUtility.SaveFilePanel("Export CSV Data", string.Empty, "Load Asset Task Data.csv", string.Empty); if (!string.IsNullOrEmpty(exportFileName)) { try { int index = 0; string[] data = new string[loadAssetInfos.Length + 1]; data[index++] = "Load Asset Name,Serial Id,Priority,Status"; foreach (TaskInfo loadAssetInfo in loadAssetInfos) { data[index++] = Utility.Text.Format("{0},{1},{2},{3}", loadAssetInfo.Description, loadAssetInfo.SerialId.ToString(), loadAssetInfo.Priority.ToString(), loadAssetInfo.Status.ToString()); } File.WriteAllLines(exportFileName, data, Encoding.UTF8); Debug.Log(Utility.Text.Format("Export load asset task CSV data to '{0}' success.", exportFileName)); } catch (Exception exception) { Debug.LogError(Utility.Text.Format("Export load asset task CSV data to '{0}' failure, exception is '{1}'.", exportFileName, exception.ToString())); } } } } else { GUILayout.Label("Load Asset Task is Empty ..."); } } EditorGUILayout.EndVertical(); } } serializedObject.ApplyModifiedProperties(); Repaint(); }