【m】更新后台
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 970f1a3c8d566a24492b32b7f48efde4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a232ea6e9816b4d4d9d694d8901e4f95
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public static class DragAndDropTool
|
||||
{
|
||||
public class DragInfo
|
||||
{
|
||||
public bool Dragging;
|
||||
public bool EnterArea;
|
||||
public bool Complete;
|
||||
public Object[] ObjectReferences => DragAndDrop.objectReferences;
|
||||
public string[] Paths => DragAndDrop.paths;
|
||||
public DragAndDropVisualMode VisualMode => DragAndDrop.visualMode;
|
||||
public int ActiveControlID => DragAndDrop.activeControlID;
|
||||
}
|
||||
|
||||
private static DragInfo mDragInfo = new DragInfo();
|
||||
|
||||
private static bool mDragging;//拖拽进区域为ture
|
||||
private static bool mEnterArea;//拖拽进content区域为ture
|
||||
private static bool mComplete;
|
||||
/// <summary>
|
||||
/// 拖拽通用方法
|
||||
/// </summary>
|
||||
/// <param name="content">检测区域</param>
|
||||
/// <param name="OnComplete">完成后的时间,利用泛型传进详细的DragInfo</param>
|
||||
/// <param name="mode"></param>
|
||||
public static void Drag(Rect content,Action<DragInfo> onComplete=null, DragAndDropVisualMode mode = DragAndDropVisualMode.Generic)
|
||||
{
|
||||
|
||||
Event e=Event.current;
|
||||
if (e.type == EventType.DragUpdated)
|
||||
{
|
||||
mComplete = false;
|
||||
mDragging = true;
|
||||
mEnterArea = content.Contains(e.mousePosition);
|
||||
if (mEnterArea)
|
||||
{
|
||||
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
|
||||
e.Use();
|
||||
}
|
||||
}
|
||||
else if (e.type == EventType.DragPerform)
|
||||
{
|
||||
mComplete = true;
|
||||
mDragging = false;
|
||||
mEnterArea = content.Contains(e.mousePosition);
|
||||
DragAndDrop.AcceptDrag();
|
||||
e.Use();
|
||||
}
|
||||
else if (e.type == EventType.DragExited)
|
||||
{
|
||||
mComplete = true;
|
||||
mDragging = false;
|
||||
mEnterArea = content.Contains(e.mousePosition);
|
||||
}
|
||||
|
||||
mDragInfo.Complete = mComplete && e.type == EventType.Used;
|
||||
mDragInfo.EnterArea = mEnterArea;
|
||||
mDragInfo.Dragging = mDragging;
|
||||
if (mDragInfo.EnterArea && mDragInfo.Complete && !mDragInfo.Dragging)
|
||||
{
|
||||
onComplete?.Invoke(mDragInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a676d8ce2e354573ae2984b51cff3b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
/****************************************************
|
||||
文件:EditorWindowLayout.cs
|
||||
作者:张铮
|
||||
邮箱:834207172@qq.com
|
||||
日期:2022/3/3 17:53:52
|
||||
功能:
|
||||
*****************************************************/
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public class EditorWindowLayout : UnoEditorLayout
|
||||
{
|
||||
public EditorWindowLayout(EditorWindow win)
|
||||
{
|
||||
_win = win;
|
||||
Margin = new Vector4(2, 2, 2, 2);
|
||||
IndentSize = 12;
|
||||
}
|
||||
|
||||
private readonly EditorWindow _win;
|
||||
|
||||
public Vector4 Margin { get; set; }
|
||||
|
||||
public void Begin()
|
||||
{
|
||||
var rect = new Rect(Margin.x, Margin.y, _win.position.width - Margin.x - Margin.z, _win.position.height - Margin.y - Margin.w);
|
||||
Begin(rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7321934936ed334d81018ca35edf12e
|
||||
timeCreated: 1511574046
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 807050751fc48ec498b43b37bf3d883f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a3caea4dd7e911429081fb9c65e995c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,123 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public enum AnchorType
|
||||
{
|
||||
UpperLeft = 0,
|
||||
UpperCenter = 1,
|
||||
UpperRight = 2,
|
||||
MiddleLeft = 3,
|
||||
MiddleCenter = 4,
|
||||
MiddleRight = 5,
|
||||
LowerLeft = 6,
|
||||
LowerCenter = 7,
|
||||
LowerRight = 8
|
||||
}
|
||||
|
||||
public static class RectExtension
|
||||
{
|
||||
/// <summary>
|
||||
///根据外层窗口缩放
|
||||
/// </summary>
|
||||
/// <param name="rect"></param>
|
||||
/// <param name="type">描点位置</param>
|
||||
/// <param name="pixel">缩放大小</param>
|
||||
/// <returns></returns>
|
||||
public static Rect Zoom(this Rect rect, AnchorType type, float pixel)
|
||||
{
|
||||
return Zoom(rect, type, new Vector2(pixel, pixel));
|
||||
}
|
||||
|
||||
public static Rect Zoom(this Rect rect, AnchorType type, Vector2 pixelOffset)
|
||||
{
|
||||
float tempW = rect.width + pixelOffset.x;
|
||||
float tempH = rect.height + pixelOffset.y;
|
||||
switch (type)
|
||||
{
|
||||
case AnchorType.UpperLeft:
|
||||
break;
|
||||
case AnchorType.UpperCenter:
|
||||
rect.x -= (tempW - rect.width) / 2;
|
||||
break;
|
||||
case AnchorType.UpperRight:
|
||||
rect.x -= tempW - rect.width;
|
||||
break;
|
||||
case AnchorType.MiddleLeft:
|
||||
rect.y -= (tempH - rect.height) / 2;
|
||||
break;
|
||||
case AnchorType.MiddleCenter:
|
||||
rect.x -= (tempW - rect.width) / 2;
|
||||
rect.y -= (tempH - rect.height) / 2;
|
||||
break;
|
||||
case AnchorType.MiddleRight:
|
||||
rect.y -= (tempH - rect.height) / 2;
|
||||
rect.x -= tempW - rect.width;
|
||||
break;
|
||||
case AnchorType.LowerLeft:
|
||||
rect.y -= tempH - rect.height;
|
||||
break;
|
||||
case AnchorType.LowerCenter:
|
||||
rect.y -= tempH - rect.height;
|
||||
rect.x -= (tempW - rect.width) / 2;
|
||||
break;
|
||||
case AnchorType.LowerRight:
|
||||
rect.y -= tempH - rect.height;
|
||||
rect.x -= tempW - rect.width;
|
||||
break;
|
||||
}
|
||||
|
||||
rect.width = tempW;
|
||||
rect.height = tempH;
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
||||
public static Rect MoveDown(this Rect r, float pixels = 1)
|
||||
{
|
||||
r.y += pixels;
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Rect CutRight(this Rect r, float pixels)
|
||||
{
|
||||
r.xMax -= pixels;
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Rect CutLeft(this Rect r, float pixels)
|
||||
{
|
||||
r.xMin += pixels;
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Rect Cut(this Rect r, float pixels)
|
||||
{
|
||||
return r.Margin(-pixels);
|
||||
}
|
||||
|
||||
public static Rect Margin(this Rect r, float pixels)
|
||||
{
|
||||
r.xMax += pixels;
|
||||
r.xMin -= pixels;
|
||||
r.yMax += pixels;
|
||||
r.yMin -= pixels;
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Rect[] VerticalSplit(this Rect r, float width, float padding = 0, bool justMid = true)
|
||||
{
|
||||
if (justMid)
|
||||
return new Rect[2]
|
||||
{
|
||||
r.CutRight((int) (r.width - width)).CutRight(padding).CutRight(-Mathf.CeilToInt(padding / 2f)),
|
||||
r.CutLeft(width).CutLeft(padding).CutLeft(-Mathf.FloorToInt(padding / 2f))
|
||||
};
|
||||
return new Rect[2]
|
||||
{
|
||||
r.CutRight((int) (r.width - width)).Cut(padding).CutRight(-Mathf.CeilToInt(padding / 2f)),
|
||||
r.CutLeft(width).Cut(padding).CutLeft(-Mathf.FloorToInt(padding / 2f))
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38c8aee9816a74cb4ae2151017cfe040
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
/****************************************************
|
||||
文件:EditorWindowLayout.cs
|
||||
作者:张铮
|
||||
邮箱:834207172@qq.com
|
||||
日期:2022/3/3 17:53:52
|
||||
功能:
|
||||
*****************************************************/
|
||||
using System;
|
||||
using System.Text;
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public class ScriptBuilder
|
||||
{
|
||||
private readonly string NEW_LINE = Environment.NewLine;
|
||||
|
||||
public ScriptBuilder()
|
||||
{
|
||||
builder = new StringBuilder();
|
||||
}
|
||||
|
||||
private StringBuilder builder;
|
||||
public int Indent { get; set; }
|
||||
|
||||
private int currentCharIndex;
|
||||
|
||||
public void Write(string val, bool noAutoIndent = false)
|
||||
{
|
||||
if (!noAutoIndent)
|
||||
val = GetIndents() + val;
|
||||
if (currentCharIndex == builder.Length)
|
||||
builder.Append(val);
|
||||
else
|
||||
builder.Insert(currentCharIndex, val);
|
||||
currentCharIndex += val.Length;
|
||||
}
|
||||
|
||||
public void WriteLine(string val, bool noAutoIndent = false)
|
||||
{
|
||||
Write(val + NEW_LINE);
|
||||
}
|
||||
|
||||
public int WriteCurlyBrackets(bool increaseIndent = false)
|
||||
{
|
||||
var openBracket = GetIndents() + "{" + NEW_LINE;
|
||||
var closeBracket = GetIndents() + "}" + NEW_LINE;
|
||||
Write(openBracket + closeBracket, true);
|
||||
currentCharIndex -= closeBracket.Length;
|
||||
if(increaseIndent)
|
||||
Indent++;
|
||||
return closeBracket.Length;
|
||||
}
|
||||
|
||||
public void GetOutOfCurlyBrackets(int lastCurlyBracketSize, bool decreaseIndent = false)
|
||||
{
|
||||
currentCharIndex += lastCurlyBracketSize;
|
||||
if (decreaseIndent)
|
||||
Indent--;
|
||||
}
|
||||
|
||||
public string GetIndents()
|
||||
{
|
||||
var str = "";
|
||||
for (var i = 0; i < Indent; i++)
|
||||
str += " ";
|
||||
return str;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a700812e31c5d849b411e1d044687ef
|
||||
timeCreated: 1582186171
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbc5b07d3d5937e4698c9518edf90bc7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public static class StringExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否是一个文件夹
|
||||
/// </summary>
|
||||
/// <param name="self"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsDirectory(this string self)
|
||||
{
|
||||
var fileInfo = new FileInfo(self);
|
||||
if ((fileInfo.Attributes & FileAttributes.Directory) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public static string ToAssetsPath(this string self)
|
||||
{
|
||||
var assetsFullPath = Path.GetFullPath(Application.dataPath);
|
||||
|
||||
return "Assets" + Path.GetFullPath(self).Substring(assetsFullPath.Length).Replace("\\", "/");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abbb0ff31d684ebfb0b17b80691110af
|
||||
timeCreated: 1635478967
|
||||
@@ -0,0 +1,448 @@
|
||||
/****************************************************
|
||||
文件:UnoEditorLayout.cs
|
||||
作者:张铮
|
||||
邮箱:834207172@qq.com
|
||||
日期:2022/3/3 17:53:52
|
||||
功能:
|
||||
*****************************************************/
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public class UnoEditorLayout
|
||||
{
|
||||
public float LineSpacing = 2;
|
||||
public int IndentCount { get; set; }
|
||||
public float IndentSize = 15;
|
||||
|
||||
private float _originX;
|
||||
|
||||
private Rect _rootRect;
|
||||
|
||||
public Rect RootRect
|
||||
{
|
||||
get
|
||||
{
|
||||
var rect = new Rect(_rootRect);
|
||||
rect.x = _originX + IndentSize * IndentCount;
|
||||
return rect;
|
||||
}
|
||||
}
|
||||
|
||||
public void Begin(Rect rect)
|
||||
{
|
||||
IndentCount = 0;
|
||||
_rootRect = rect;
|
||||
_originX = _rootRect.x;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移至新的一行
|
||||
/// </summary>
|
||||
/// <param name="height"></param>
|
||||
/// <returns>返回前一行的Rect</returns>
|
||||
public Rect NextLine(float height = 0, float lineSpacing = -1)
|
||||
{
|
||||
if (height <= 0)
|
||||
height = EditorGUIUtility.singleLineHeight;
|
||||
if (lineSpacing < 0)
|
||||
lineSpacing = LineSpacing;
|
||||
var rect = new Rect(RootRect);
|
||||
rect.height = height;
|
||||
var delta = height + lineSpacing;
|
||||
_rootRect.y += delta;
|
||||
_rootRect.height -= delta;
|
||||
return rect;
|
||||
}
|
||||
|
||||
public Rect SingleLine(float height = 0f)
|
||||
{
|
||||
return CreateRow(new[] { LayoutDef.Any() }, height)[0];
|
||||
}
|
||||
|
||||
public Rect[] CreateRow(LayoutDef[] lDefs, float height = 0f, float gap = 4f, Rect? rect = null, Rect[] result = null)
|
||||
{
|
||||
if (height <= 0)
|
||||
height = EditorGUIUtility.singleLineHeight;
|
||||
return CreateRects(lDefs, false, height, gap, rect, result);
|
||||
}
|
||||
|
||||
public static Rect[] CreateRow(LayoutDef[] lDefs, Rect rect, float height = 0f, float gap = 4f, Rect[] result = null)
|
||||
{
|
||||
return CreateRects(lDefs, rect, false, height, gap, result);
|
||||
}
|
||||
|
||||
public Rect[] CreateColum(LayoutDef[] lDefs, float width = 0f, float gap = 4f, Rect? rect = null, Rect[] result = null)
|
||||
{
|
||||
return CreateRects(lDefs, true, width, gap, rect, result);
|
||||
}
|
||||
|
||||
public static Rect[] CreateColum(LayoutDef[] lDefs, Rect rect, float width = 0f, float gap = 4f, Rect[] result = null)
|
||||
{
|
||||
return CreateRects(lDefs, rect, true, width, gap, result);
|
||||
}
|
||||
|
||||
private Rect[] CreateRects(LayoutDef[] lDefs, bool isVertical, float otherEdgeLength = 0f, float gap = 4, Rect? rect = null, Rect[] result = null)
|
||||
{
|
||||
rect = rect ?? RootRect;
|
||||
return CreateRects(lDefs, rect.Value, isVertical, otherEdgeLength, gap, result);
|
||||
}
|
||||
|
||||
public static Rect[] CreateRects(LayoutDef[] lDefs, Rect r, bool isVertical, float otherEdgeLength = 0f, float gap = 4, Rect[] result = null)
|
||||
{
|
||||
if (result != null && result.Length != lDefs.Length)
|
||||
throw new ArgumentException("the length of result does not match to length of lDefs");
|
||||
if (otherEdgeLength <= 0)
|
||||
{
|
||||
if (isVertical)
|
||||
otherEdgeLength = r.width;
|
||||
else
|
||||
otherEdgeLength = r.height;
|
||||
}
|
||||
|
||||
var totalSpace = isVertical ? r.height : r.width;
|
||||
var spaceLeft = totalSpace;
|
||||
var currentPos = isVertical ? r.y : r.x;
|
||||
var anyCount = lDefs.Length;
|
||||
result = result ?? new Rect[lDefs.Length];
|
||||
for (var i = 0; i < lDefs.Length; i++)
|
||||
{
|
||||
var ld = lDefs[i];
|
||||
float val = 0;
|
||||
if (!ld.IsAny)
|
||||
{
|
||||
val = ld.RatioWise ? GetPercentageVal(ld, totalSpace, lDefs.Length, gap) : ld.Value;
|
||||
val = ClampValueFromVector2(val, ld.MinSize, ld.MaxSize, isVertical);
|
||||
spaceLeft -= val;
|
||||
anyCount--;
|
||||
}
|
||||
else if (ld.Value > 0)
|
||||
{
|
||||
val = ld.Value + gap;
|
||||
spaceLeft -= val;
|
||||
anyCount--;
|
||||
}
|
||||
|
||||
if (isVertical)
|
||||
{
|
||||
result[i].height = val;
|
||||
result[i].width = otherEdgeLength;
|
||||
result[i].x = r.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
result[i].width = val;
|
||||
result[i].height = otherEdgeLength;
|
||||
result[i].y = r.y;
|
||||
}
|
||||
|
||||
spaceLeft -= gap;
|
||||
}
|
||||
|
||||
spaceLeft += gap;
|
||||
|
||||
var anySize = spaceLeft / anyCount;
|
||||
for (var i = 0; i < lDefs.Length; i++)
|
||||
{
|
||||
var ld = lDefs[i];
|
||||
if (!ld.IsAny || !ld.MinSize.HasValue)
|
||||
continue;
|
||||
var size = 0f;
|
||||
var minSize = isVertical ? ld.MinSize.Value.y : ld.MinSize.Value.x;
|
||||
if (anySize < minSize)
|
||||
size = minSize;
|
||||
if (size <= 0)
|
||||
continue;
|
||||
|
||||
anyCount--;
|
||||
spaceLeft -= size;
|
||||
lDefs[i].Value = size;
|
||||
if (isVertical)
|
||||
result[i].height = size;
|
||||
else
|
||||
result[i].width = size;
|
||||
}
|
||||
|
||||
anySize = spaceLeft / anyCount;
|
||||
|
||||
for (var i = 0; i < lDefs.Length; i++)
|
||||
{
|
||||
var ld = lDefs[i];
|
||||
if (!ld.IsAny || !ld.MaxSize.HasValue)
|
||||
continue;
|
||||
var size = 0f;
|
||||
|
||||
var maxSize = isVertical ? ld.MaxSize.Value.y : ld.MaxSize.Value.x;
|
||||
if (anySize > maxSize)
|
||||
size = maxSize;
|
||||
|
||||
if (size <= 0)
|
||||
continue;
|
||||
|
||||
anyCount--;
|
||||
spaceLeft -= size;
|
||||
lDefs[i].Value = size;
|
||||
if (isVertical)
|
||||
result[i].height = size;
|
||||
else
|
||||
result[i].width = size;
|
||||
}
|
||||
|
||||
anySize = spaceLeft / anyCount;
|
||||
for (var i = 0; i < lDefs.Length; i++)
|
||||
{
|
||||
var ld = lDefs[i];
|
||||
float val;
|
||||
if (isVertical)
|
||||
{
|
||||
if (ld.IsAny)
|
||||
{
|
||||
result[i].height = anySize;
|
||||
val = anySize;
|
||||
}
|
||||
else
|
||||
val = result[i].height;
|
||||
|
||||
result[i].y = currentPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ld.IsAny)
|
||||
{
|
||||
result[i].width = anySize;
|
||||
val = anySize;
|
||||
}
|
||||
else
|
||||
val = result[i].width;
|
||||
|
||||
result[i].x = currentPos;
|
||||
}
|
||||
|
||||
currentPos += val + gap;
|
||||
//Debug.Log(result[i].x + ", " + result[i].width);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Rect[][] CreateGrid(LayoutDef[] hlDefs, LayoutDef[] vlDefs, float gap = 4, Rect? rect = null)
|
||||
{
|
||||
rect = rect ?? RootRect;
|
||||
return CreateGrid(hlDefs, vlDefs, rect.Value, gap);
|
||||
}
|
||||
|
||||
public static Rect[][] CreateGrid(LayoutDef[] hlDefs, LayoutDef[] vlDefs, Rect rect, float gap = 4)
|
||||
{
|
||||
var result = new Rect[vlDefs.Length][];
|
||||
var row = CreateRects(hlDefs, rect, false, 0, gap);
|
||||
result[0] = row;
|
||||
for (var i = 1; i < vlDefs.Length; i++)
|
||||
{
|
||||
result[i] = new Rect[row.Length];
|
||||
for (var j = 0; j < row.Length; j++)
|
||||
{
|
||||
result[i][j] = row[j];
|
||||
}
|
||||
}
|
||||
|
||||
var col = CreateRects(vlDefs, rect, true, 0, gap);
|
||||
for (var i = 0; i < vlDefs.Length; i++)
|
||||
{
|
||||
for (var j = 0; j < result[i].Length; j++)
|
||||
{
|
||||
result[i][j].height = col[i].height;
|
||||
result[i][j].y = col[i].y;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="hlDefs"></param>
|
||||
/// <param name="vlDefs"></param>
|
||||
/// <param name="gap"></param>
|
||||
/// <param name="rect"></param>
|
||||
/// <returns>result[i] represents a row</returns>
|
||||
public Rect[][] CreateGridUnevenColum(LayoutDef[][] hlDefs, LayoutDef[] vlDefs, float gap = 4, Rect? rect = null)
|
||||
{
|
||||
rect = rect ?? RootRect;
|
||||
|
||||
return CreateGridUnevenColum(hlDefs, vlDefs, rect.Value, gap);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="hlDefs"></param>
|
||||
/// <param name="vlDefs"></param>
|
||||
/// <param name="gap"></param>
|
||||
/// <param name="rect"></param>
|
||||
/// <returns>result[i] represents a row</returns>
|
||||
public static Rect[][] CreateGridUnevenColum(LayoutDef[][] hlDefs, LayoutDef[] vlDefs, Rect rect, float gap = 4)
|
||||
{
|
||||
if (hlDefs.Length != vlDefs.Length)
|
||||
throw new ArgumentException("the length of hlDefs must match with the length of vlDefs");
|
||||
|
||||
var result = new Rect[vlDefs.Length][];
|
||||
for (var i = 0; i < vlDefs.Length; i++)
|
||||
{
|
||||
result[i] = CreateRects(hlDefs[i], rect, false, 0, gap);
|
||||
}
|
||||
|
||||
var col = CreateRects(vlDefs, rect, true, 0, gap);
|
||||
for (var i = 0; i < vlDefs.Length; i++)
|
||||
{
|
||||
var row = result[i];
|
||||
for (var j = 0; j < row.Length; j++)
|
||||
{
|
||||
row[j].height = col[i].height;
|
||||
row[j].y = col[i].y;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="hlDefs"></param>
|
||||
/// <param name="vlDefs"></param>
|
||||
/// <param name="gap"></param>
|
||||
/// <param name="rect"></param>
|
||||
/// <returns>result[i] represents a colum</returns>
|
||||
public Rect[][] CreateGridUnevenRow(LayoutDef[] hlDefs, LayoutDef[][] vlDefs, float gap = 4, Rect? rect = null)
|
||||
{
|
||||
rect = rect ?? RootRect;
|
||||
return CreateGridUnevenRow(hlDefs, vlDefs, rect.Value, gap);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="hlDefs"></param>
|
||||
/// <param name="vlDefs"></param>
|
||||
/// <param name="gap"></param>
|
||||
/// <param name="rect"></param>
|
||||
/// <returns>result[i] represents a colum</returns>
|
||||
public static Rect[][] CreateGridUnevenRow(LayoutDef[] hlDefs, LayoutDef[][] vlDefs, Rect rect, float gap = 4)
|
||||
{
|
||||
if (hlDefs.Length != vlDefs.Length)
|
||||
throw new ArgumentException("the length of hlDefs must match with the length of vlDefs");
|
||||
var result = new Rect[vlDefs.Length][];
|
||||
for (var i = 0; i < vlDefs.Length; i++)
|
||||
{
|
||||
result[i] = CreateRects(vlDefs[i], rect, true, 0, gap);
|
||||
}
|
||||
|
||||
var row = CreateRects(hlDefs, rect, false, 0, gap);
|
||||
for (var i = 0; i < row.Length; i++)
|
||||
{
|
||||
for (var j = 0; j < result[i].Length; j++)
|
||||
{
|
||||
result[i][j].width = row[i].width;
|
||||
result[i][j].x = row[i].x;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Vector2 EvaluateTextSize(GUIContent text, GUIStyle guiStyle = null)
|
||||
{
|
||||
if (guiStyle == null)
|
||||
guiStyle = EditorStyles.label;
|
||||
|
||||
return guiStyle.CalcSize(text);
|
||||
}
|
||||
|
||||
public static Vector2 EvaluateTextSize(string text, GUIStyle guiStyle = null)
|
||||
{
|
||||
return EvaluateTextSize(new GUIContent(text), guiStyle);
|
||||
}
|
||||
|
||||
private static float ClampValueFromVector2(float val, Vector2? min, Vector2? max, bool byY)
|
||||
{
|
||||
if (byY)
|
||||
{
|
||||
return Mathf.Clamp(val,
|
||||
min.HasValue ? min.Value.y : float.MinValue,
|
||||
max.HasValue ? max.Value.y : float.MaxValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Mathf.Clamp(val,
|
||||
min.HasValue ? min.Value.x : float.MinValue,
|
||||
max.HasValue ? max.Value.x : float.MaxValue);
|
||||
}
|
||||
}
|
||||
|
||||
private static float GetPercentageVal(LayoutDef ld, float totalSpace, int numChildren, float gap)
|
||||
{
|
||||
return (totalSpace - (numChildren - 1) * gap) * ld.Value * .01f;
|
||||
}
|
||||
}
|
||||
|
||||
public struct LayoutDef
|
||||
{
|
||||
public static LayoutDef Any()
|
||||
{
|
||||
return new LayoutDef();
|
||||
}
|
||||
|
||||
public static LayoutDef Val(float value)
|
||||
{
|
||||
return new LayoutDef { Value = value };
|
||||
}
|
||||
|
||||
public static LayoutDef Percentage(float percentage)
|
||||
{
|
||||
return new LayoutDef { Value = percentage, RatioWise = true };
|
||||
}
|
||||
|
||||
public static LayoutDef[] EquallyDivide(int num)
|
||||
{
|
||||
var arr = new LayoutDef[num];
|
||||
//default(LayoutDef) == LayoutDef.Any()
|
||||
return arr;
|
||||
}
|
||||
|
||||
public float Value { get; set; }
|
||||
public bool RatioWise { get; set; }
|
||||
public Vector2? MinSize { get; private set; }
|
||||
public Vector2? MaxSize { get; private set; }
|
||||
|
||||
public LayoutDef WithMinSize(Vector2 minSize)
|
||||
{
|
||||
MinSize = minSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LayoutDef WithMaxSize(Vector2 maxSize)
|
||||
{
|
||||
MaxSize = maxSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LayoutDef WithMinSize(float x, float y)
|
||||
{
|
||||
MinSize = new Vector2(x, y);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LayoutDef WithMaxSize(float x, float y)
|
||||
{
|
||||
MaxSize = new Vector2(x, y);
|
||||
return this;
|
||||
}
|
||||
|
||||
public bool IsAny
|
||||
{
|
||||
get { return Value == 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fa325b0a38cdb84bb0d9125492a3211
|
||||
timeCreated: 1597995623
|
||||
@@ -0,0 +1,292 @@
|
||||
/****************************************************
|
||||
文件:UtilityEditor.cs
|
||||
作者:张铮
|
||||
邮箱:834207172@qq.com
|
||||
日期:2022/3/3 17:53:52
|
||||
功能:
|
||||
*****************************************************/
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public class UtilityEditor
|
||||
{
|
||||
|
||||
[MenuItem("Evo/Utility/优化/检查模型/一键压缩模型的mesh")]
|
||||
static void 一键压缩所有模型的mesh()
|
||||
{
|
||||
AssetDatabase.StartAssetEditing();
|
||||
int count = 0;
|
||||
foreach (var guid in AssetDatabase.FindAssets("t:Model"))
|
||||
{
|
||||
var assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var textureImporter = AssetImporter.GetAtPath(assetPath) as ModelImporter;
|
||||
if (textureImporter == null)
|
||||
continue;
|
||||
if (textureImporter.meshCompression != ModelImporterMeshCompression.Off)
|
||||
{
|
||||
textureImporter.meshCompression = ModelImporterMeshCompression.Off;
|
||||
textureImporter.SaveAndReimport();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
Debug.Log("压缩了:" + count + "个模型");
|
||||
AssetDatabase.StopAssetEditing();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
[MenuItem("Evo/Utility/优化/检查模型/选择文件夹压缩模型mesh")]
|
||||
static void 选择文件夹压缩模型mesh()
|
||||
{
|
||||
if (Selection.objects.Length != 1)
|
||||
{
|
||||
Debug.LogError("选择一个文件夹");
|
||||
return;
|
||||
}
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(Selection.objects[0]);
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Debug.Log(path);
|
||||
return;
|
||||
}
|
||||
|
||||
AssetDatabase.StartAssetEditing();
|
||||
int count = 0;
|
||||
string[] filePath = GetFilePath(Selection.objects);
|
||||
foreach (var guid in AssetDatabase.FindAssets("t:Model", filePath))
|
||||
{
|
||||
|
||||
var assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var textureImporter = AssetImporter.GetAtPath(assetPath) as ModelImporter;
|
||||
if (textureImporter == null)
|
||||
continue;
|
||||
if (textureImporter.meshCompression != ModelImporterMeshCompression.Off)
|
||||
{
|
||||
Debug.Log(assetPath);
|
||||
textureImporter.meshCompression = ModelImporterMeshCompression.Off;
|
||||
textureImporter.SaveAndReimport();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log("处理了:" + count + "个模型");
|
||||
AssetDatabase.StopAssetEditing();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
[MenuItem("Evo/Utility/优化/检查模型/去除文件夹内模型的ReadWrite")]
|
||||
static void 去除文件夹内模型的ReadWrite()
|
||||
{
|
||||
if (Selection.objects.Length != 1)
|
||||
{
|
||||
Debug.LogError("选择一个文件夹");
|
||||
return;
|
||||
}
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(Selection.objects[0]);
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Debug.Log(path);
|
||||
return;
|
||||
}
|
||||
|
||||
AssetDatabase.StartAssetEditing();
|
||||
int count = 0;
|
||||
string[] filePath = GetFilePath(Selection.objects);
|
||||
foreach (var guid in AssetDatabase.FindAssets("t:Model", filePath))
|
||||
{
|
||||
var assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var textureImporter = AssetImporter.GetAtPath(assetPath) as ModelImporter;
|
||||
if (textureImporter == null)
|
||||
continue;
|
||||
if (textureImporter.isReadable)
|
||||
{
|
||||
Debug.Log(assetPath);
|
||||
textureImporter.isReadable = false;
|
||||
textureImporter.SaveAndReimport();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log("处理了:" + count + "个模型");
|
||||
AssetDatabase.StopAssetEditing();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
public static string[] GetFilePath(Object[] targets)
|
||||
{
|
||||
var folders = new List<string>();
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(targets[i]);
|
||||
if (Directory.Exists(assetPath))
|
||||
folders.Add(assetPath);
|
||||
}
|
||||
|
||||
return folders.ToArray();
|
||||
}
|
||||
|
||||
[MenuItem("Evo/Utility/优化/检查模型/一键压缩模型的动画为Optimal")]
|
||||
static void 一键压缩模型的动画()
|
||||
{
|
||||
AssetDatabase.StartAssetEditing();
|
||||
int count = 0;
|
||||
foreach (var guid in AssetDatabase.FindAssets("t:Model"))
|
||||
{
|
||||
var assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var textureImporter = AssetImporter.GetAtPath(assetPath) as ModelImporter;
|
||||
if (textureImporter == null)
|
||||
continue;
|
||||
if (textureImporter.animationCompression != ModelImporterAnimationCompression.Optimal)
|
||||
{
|
||||
Debug.Log(assetPath);
|
||||
textureImporter.animationCompression = ModelImporterAnimationCompression.Optimal;
|
||||
textureImporter.SaveAndReimport();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log("处理了:" + count + "个模型");
|
||||
AssetDatabase.StopAssetEditing();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
[MenuItem("Evo/Utility/优化/检查图片/去除文件夹内图片的ReadWrite")]
|
||||
static void 去除文件夹内图片的ReadWrite()
|
||||
{
|
||||
if (Selection.objects.Length != 1)
|
||||
{
|
||||
Debug.LogError("选择一个文件夹");
|
||||
return;
|
||||
}
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(Selection.objects[0]);
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Debug.Log(path);
|
||||
return;
|
||||
}
|
||||
|
||||
AssetDatabase.StartAssetEditing();
|
||||
int count = 0;
|
||||
string[] filePath = GetFilePath(Selection.objects);
|
||||
foreach (var guid in AssetDatabase.FindAssets("t:Texture", filePath))
|
||||
{
|
||||
var assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;
|
||||
if (textureImporter == null)
|
||||
continue;
|
||||
if (textureImporter.isReadable)
|
||||
{
|
||||
Debug.Log(assetPath);
|
||||
textureImporter.isReadable = false;
|
||||
textureImporter.SaveAndReimport();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log("处理了:" + count + "个图片");
|
||||
AssetDatabase.StopAssetEditing();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
[MenuItem("Evo/Utility/优化/检查图片/去除文件夹内图片的mipmap")]
|
||||
static void 去除文件夹内图片的mipmap()
|
||||
{
|
||||
if (Selection.objects.Length != 1)
|
||||
{
|
||||
Debug.LogError("选择一个文件夹");
|
||||
return;
|
||||
}
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(Selection.objects[0]);
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Debug.Log(path);
|
||||
return;
|
||||
}
|
||||
|
||||
AssetDatabase.StartAssetEditing();
|
||||
int count = 0;
|
||||
string[] filePath = GetFilePath(Selection.objects);
|
||||
foreach (var guid in AssetDatabase.FindAssets("t:Texture", filePath))
|
||||
{
|
||||
var assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;
|
||||
if (textureImporter == null)
|
||||
continue;
|
||||
if (textureImporter.mipmapEnabled)
|
||||
{
|
||||
Debug.Log(assetPath);
|
||||
textureImporter.mipmapEnabled = false;
|
||||
textureImporter.SaveAndReimport();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log("处理了:" + count + "个图片");
|
||||
AssetDatabase.StopAssetEditing();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
private static void DeleteEmptyDirectory(DirectoryInfo directory)
|
||||
{
|
||||
DirectoryInfo[] childDirectory = directory.GetDirectories();
|
||||
|
||||
if (childDirectory.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < childDirectory.Length; i++)
|
||||
{
|
||||
DeleteEmptyDirectory(childDirectory[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (directory.GetFileSystemInfos().Length == 0)
|
||||
{
|
||||
string path = directory.FullName;
|
||||
int index = path.IndexOf("Assets");
|
||||
path = path.Remove(0, index);
|
||||
directory.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开文件夹
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
public static void OpenDirectory(string path)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (string.IsNullOrEmpty(path)) return;
|
||||
path = path.Replace("/", "\\");
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Debug.LogError("No Directory: " + path);
|
||||
return;
|
||||
}
|
||||
|
||||
System.Diagnostics.Process.Start("explorer.exe", path);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件夹下所有文件路径
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="extension">"*.mp3"</param>
|
||||
/// <returns></returns>
|
||||
public static string[] GetFiles(string path, string extension = "*")
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return Directory.GetFiles(path, extension, SearchOption.AllDirectories);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58460c25029e7b84c87ff61ae21746a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user