12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- //------------------------------------------------------------
- // Game Framework
- // Copyright © 2013-2021 loyalsoft. All rights reserved.
- // Homepage: http://www.game7000.com/
- // Feedback: http://www.game7000.com/
- //------------------------------------------------------------
- using GameFramework;
- using GameFramework.FileSystem;
- using UnityEditor;
- using UnityGameFramework.Runtime;
- namespace UnityGameFramework.Editor
- {
- [CustomEditor(typeof(FileSystemComponent))]
- internal sealed class FileSystemComponentInspector : GameFrameworkInspector
- {
- private HelperInfo<FileSystemHelperBase> m_FileSystemHelperInfo = new HelperInfo<FileSystemHelperBase>("FileSystem");
- public override void OnInspectorGUI()
- {
- base.OnInspectorGUI();
- FileSystemComponent t = (FileSystemComponent)target;
- EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
- {
- m_FileSystemHelperInfo.Draw();
- }
- EditorGUI.EndDisabledGroup();
- if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
- {
- EditorGUILayout.LabelField("File System Count", t.Count.ToString());
- IFileSystem[] fileSystems = t.GetAllFileSystems();
- foreach (IFileSystem fileSystem in fileSystems)
- {
- DrawFileSystem(fileSystem);
- }
- }
- serializedObject.ApplyModifiedProperties();
- Repaint();
- }
- protected override void OnCompileComplete()
- {
- base.OnCompileComplete();
- RefreshTypeNames();
- }
- private void OnEnable()
- {
- m_FileSystemHelperInfo.Init(serializedObject);
- RefreshTypeNames();
- }
- private void RefreshTypeNames()
- {
- m_FileSystemHelperInfo.Refresh();
- serializedObject.ApplyModifiedProperties();
- }
- private void DrawFileSystem(IFileSystem fileSystem)
- {
- EditorGUILayout.LabelField(fileSystem.FullPath, Utility.Text.Format("{0}, {1} / {2} Files", fileSystem.Access.ToString(), fileSystem.FileCount.ToString(), fileSystem.MaxFileCount.ToString()));
- }
- }
- }
|