框架上传
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public class FolderField : GUIBase
|
||||
{
|
||||
public FolderField(string path = "Assets/", string folder = "Assets", string title = "Select Folder",
|
||||
string defaultName = "")
|
||||
{
|
||||
mPath = path;
|
||||
Title = title;
|
||||
Folder = folder;
|
||||
DefaultName = defaultName;
|
||||
}
|
||||
|
||||
protected string mPath;
|
||||
|
||||
|
||||
public string Path => mPath;
|
||||
public string Title;
|
||||
public string Folder;
|
||||
public string DefaultName;
|
||||
|
||||
public void SetPath(string path)
|
||||
{
|
||||
mPath = path;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position)
|
||||
{
|
||||
base.OnGUI(position);
|
||||
|
||||
var rects = position.VerticalSplit(position.width - 30);
|
||||
var leftRect = rects[0];
|
||||
var rightRect = rects[1];
|
||||
|
||||
var currentGUIEnabled = GUI.enabled;
|
||||
GUI.enabled = false;
|
||||
EditorGUI.TextField(leftRect, mPath); // 左边的 rect width - 30
|
||||
GUI.enabled = currentGUIEnabled;
|
||||
|
||||
if (GUI.Button(rightRect,GUIContents.Folder)) // 右边的 rect 30
|
||||
{
|
||||
var path = EditorUtility.OpenFolderPanel(Title, Folder, DefaultName);
|
||||
|
||||
if (!string.IsNullOrEmpty(path) && path.IsDirectory())
|
||||
{
|
||||
mPath = path.ToAssetsPath()+"/";
|
||||
}
|
||||
}
|
||||
|
||||
DragAndDropTool.Drag(leftRect, OnComplete);
|
||||
|
||||
}
|
||||
private void OnComplete(DragAndDropTool.DragInfo info)
|
||||
{
|
||||
if (info.Paths[0].IsDirectory())
|
||||
{
|
||||
mPath = info.Paths[0]+"/";
|
||||
}
|
||||
}
|
||||
protected override void OnDispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40b6b51b847f2bd41a6547694b94611f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public abstract class GUIBase :IDisposable
|
||||
{
|
||||
public bool mDisposed { get; protected set; }
|
||||
public Rect mPosition { get; protected set; }
|
||||
|
||||
public virtual void OnGUI(Rect position)
|
||||
{
|
||||
mPosition = position;
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
if(mDisposed) return;
|
||||
OnDispose();
|
||||
mDisposed = true;
|
||||
}
|
||||
|
||||
protected abstract void OnDispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0bfad764209a8ea469e5934f7cfae937
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public class GUIContents
|
||||
{
|
||||
public static GUIContent Folder = EditorGUIUtility.IconContent("Folder Icon");
|
||||
public static GUIContent FolderEmpty = EditorGUIUtility.IconContent("FolderEmpty Icon");
|
||||
// 等等
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 314d1168ba299ae488188c679eabf657
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user