文章出處

using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
using System.Text;
using System.IO;
using System;

 

namespace Daemo
{

public class BaseEditor : Editor
{

/// <summary>
/// 切割路徑
/// </summary>
protected static string SplitPath(string path, string s)
{
string[] ss = path.Split('/');
string result = "";
bool flat = false;
for (int i = 0; i < ss.Length; i++)
{
if (flat)
{
result = result + "/" + ss[i];
}
if (!flat && ss[i] == s)
{
flat = true;
}
}
return result;
}

#region 遍歷文件夾

//遍歷文件夾
public static void HandlelDirections(string path, Action<string> action)
{
HandleLocalFiles(path, action);
string[] childrenPaths = Directory.GetDirectories(path);
foreach (string childPath in childrenPaths)
{
HandlelDirections(childPath, action);
}
}
public static void HandleLocalFiles(string path, Action<string> action)
{
string[] files = Directory.GetFiles(path);
for (int i = 0; i < files.Length; i++)
{
string file = files[i];
file = file.Replace(@"\",@"/");
action(file);
}
}

#endregion

#region 遍歷子節點

public static void CycleChild(Transform t, Action<Transform> action)
{
action(t);
for (int i = 0; i < t.childCount; i++)
{

if (t.childCount > 0)
CycleChild(t.GetChild(i), action);
}
}

#endregion

}

}

 


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜

    大師兄 發表在 痞客邦 留言(0) 人氣()