diff --git a/FrameCapturer/Assets/UTJ/FrameCapturer/Editor/Misc/DataPathDrawer.cs b/FrameCapturer/Assets/UTJ/FrameCapturer/Editor/Misc/DataPathDrawer.cs index 0533f21b..5255a379 100644 --- a/FrameCapturer/Assets/UTJ/FrameCapturer/Editor/Misc/DataPathDrawer.cs +++ b/FrameCapturer/Assets/UTJ/FrameCapturer/Editor/Misc/DataPathDrawer.cs @@ -17,13 +17,27 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; + float buttonWidth = 22; float rootWidth = 70; - float leafWidth = position.width - rootWidth - 5; - Rect rootRect = new Rect(position.x, position.y, rootWidth, position.height); - Rect leafRect = new Rect(position.x + rootWidth + 5, position.y, leafWidth, position.height); + float leafWidth = position.width - rootWidth - 5 - buttonWidth; + var rootRect = new Rect(position.x, position.y, rootWidth, position.height); + var leafRect = new Rect(position.x + rootWidth + 5, position.y, leafWidth, position.height); + var buttonRect = new Rect(position.x + rootWidth + 5 + leafWidth, position.y, buttonWidth, position.height); - EditorGUI.PropertyField(rootRect, property.FindPropertyRelative("m_root"), GUIContent.none); - EditorGUI.PropertyField(leafRect, property.FindPropertyRelative("m_leaf"), GUIContent.none); + var pRoot = property.FindPropertyRelative("m_root"); + var pLeaf = property.FindPropertyRelative("m_leaf"); + EditorGUI.PropertyField(rootRect, pRoot, GUIContent.none); + EditorGUI.PropertyField(leafRect, pLeaf, GUIContent.none); + if (GUI.Button(buttonRect, "...")) + { + var path = EditorUtility.OpenFolderPanel("Output Directory", ".", ""); + if (path.Length > 0) + { + var newPath = new DataPath(path); + pRoot.intValue = (int)newPath.root; + pLeaf.stringValue = newPath.leaf; + } + } EditorGUI.indentLevel = indent; EditorGUI.EndProperty(); diff --git a/FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Misc/DataPath.cs b/FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Misc/DataPath.cs index e11f22f1..31b8e3d2 100644 --- a/FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Misc/DataPath.cs +++ b/FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Misc/DataPath.cs @@ -56,27 +56,36 @@ public DataPath(string path) if (path.Contains(Application.streamingAssetsPath)) { m_root = Root.StreamingAssets; - m_leaf = path.Replace(Application.streamingAssetsPath, ""); + m_leaf = path.Replace(Application.streamingAssetsPath, "").TrimStart('/'); } else if (path.Contains(Application.dataPath)) { m_root = Root.DataPath; - m_leaf = path.Replace(Application.dataPath, ""); + m_leaf = path.Replace(Application.dataPath, "").TrimStart('/'); } else if (path.Contains(Application.persistentDataPath)) { m_root = Root.PersistentData; - m_leaf = path.Replace(Application.persistentDataPath, ""); + m_leaf = path.Replace(Application.persistentDataPath, "").TrimStart('/'); } else if (path.Contains(Application.temporaryCachePath)) { m_root = Root.TemporaryCache; - m_leaf = path.Replace(Application.temporaryCachePath, ""); + m_leaf = path.Replace(Application.temporaryCachePath, "").TrimStart('/'); } else { - m_root = Root.Absolute; - m_leaf = path; + var cur = System.IO.Directory.GetCurrentDirectory().Replace("\\", "/"); + if (path.Contains(cur)) + { + m_root = Root.Current; + m_leaf = path.Replace(cur, "").TrimStart('/'); + } + else + { + m_root = Root.Absolute; + m_leaf = path; + } } }