zoukankan      html  css  js  c++  java
  • BaseEditor

    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

    }

    }

  • 相关阅读:
    BZOJ3575 [Hnoi2014]道路堵塞
    BZOJ4456/UOJ184 [Zjoi2016]旅行者
    BZOJ4455/UOJ185 [Zjoi2016]小星星
    BZOJ1036 [ZJOI2008]树的统计Count
    BZOJ2594 [Wc2006]水管局长数据加强版
    BZOJ3669/UOJ3 魔法森林(LCT)
    BZOJ1012:[JSOI2008]最大数
    洛谷【P1175】表达式的转换
    HDU4699:Editor
    BZOJ3039:玉蟾宫
  • 原文地址:https://www.cnblogs.com/rexzhao/p/7243168.html
Copyright © 2011-2022 走看看