Ejemplo n.º 1
0
        [MenuItem("Help/将Dll放进来 %q")]                        //Ctrl + Q
        static void PullDllComeIn()
        {
            string savePath = Application.dataPath;
            string firstDllPath;

            if (OpenWindow.ChooseFile(@"F:\MyNewDll", out firstDllPath))
            {
                string fileName = MyAssetUtil.GetFileNameByFullName(firstDllPath);
                if (!MyAssetUtil.GetFileSuffix(fileName).Equals("dll"))
                {
                    MyLog.Orange("选择的文件不是dll ——" + fileName);
                    return;
                }
                string saveDllPath;
                if (OpenWindow.ChooseFloder(savePath, out saveDllPath))
                {
                    saveDllPath = saveDllPath + "/" + fileName;
                    MyIO.FileCopy(firstDllPath, saveDllPath);
                }
                else
                {
                    MyLog.Green("取消操作");
                }
            }
            else
            {
                MyLog.Green("取消操作");
            }
            AssetDatabase.Refresh();
        }
Ejemplo n.º 2
0
        private void DrawKey()                                  // 快捷键
        {
            MyCreate.Box(() =>
            {
                m_Tools.TextText_BL("Ctrl + W", "复制 UGUI 名到剪切版", -50);
                m_Tools.Text_G("使用它,再也不用烦找名字的痛苦了");
            });
            AddSpace();


            MyCreate.Box(() =>
            {
                m_Tools.Text_Y("先点击选择多个图片,给它们添加前缀");
                Texture2D[] texs = Selection.GetFiltered <Texture2D>(SelectionMode.Assets);
                bool isCanClick  = (null == texs || texs.Length <= 0);
                GUI.enabled      = !isCanClick;
                MyCreate.Button("    一键添加前缀", () =>
                {
                    foreach (Texture2D texture2 in texs)
                    {
                        string assetPath = AssetDatabase.GetAssetPath(texture2);
                        string fullPath  = MyAssetUtil.GetFullPath(assetPath);
                        string fileName  = MyAssetUtil.GetFileNameByFullName(fullPath);
                        MyIO.FileRename(fullPath, "EX_" + fileName);
                    }

                    AssetDatabase.Refresh();
                });


                GUI.enabled = true;
            });
        }
Ejemplo n.º 3
0
    /// <summary>
    /// 查找所有 *.unity 的场景
    /// </summary>
    /// <param name="isShowAll">是否显示所有</param>
    /// <returns></returns>
    public static Dictionary <string, string> FindAllUnityScene(bool isShowAll = false)
    {
        string[] untiyFileFullPaths = Directory.GetFiles(Application.dataPath, "*.unity", SearchOption.AllDirectories);

        Dictionary <string, string> nameK_AssetPathV = new Dictionary <string, string>();

        foreach (string fullPath in untiyFileFullPaths)
        {
            if (!isShowAll)
            {
                if (fullPath.Contains("\\_AssetBundleResources") || fullPath.Contains("\\Plugins"))      // 不包含需要打包出去的 AssetBundle 包中的场景
                {
                    continue;
                }
            }
            string name      = MyAssetUtil.GetFileNameByFullNameNoSuffix(fullPath);
            string assetPath = MyAssetUtil.GetAssetsBackPath(fullPath);
            if (nameK_AssetPathV.ContainsKey(name))
            {
                MyLog.Red("有相同名字的场景,修改一下");
            }
            else
            {
                nameK_AssetPathV.Add(name, assetPath);
            }
        }
        return(nameK_AssetPathV);
    }
Ejemplo n.º 4
0
 private void SaveTu()                                    // 保存图片
 {
     foreach (string path in pathK_ImageV.Keys)
     {
         string resPath = Application.dataPath + "/GameAssets/Sprite/" + MyAssetUtil.GetFileNameByFullName(path);
         // 将图片复制 "/GameAssets/Sprite/" 文件夹下
         MyIO.FileCopy(path, resPath);
         string assetPath = MyAssetUtil.GetAssetsBackPath(resPath);
         AssetDatabase.Refresh();
         // 转化成 Sprite
         Texture2DChangeSprite(assetPath);
         ; Sprite sp = AssetDatabase.LoadAssetAtPath <Sprite>(assetPath);
         pathK_ImageV[path].sprite = sp;
     }
     pathK_ImageV.Clear();
 }
Ejemplo n.º 5
0
 protected override void OnEditorGUI()
 {
     MyCreate.Button("            【将所有 cs 文件转化 utf-8 格式】 点击运行", () =>
     {
         string path = MyAssetUtil.GetApplicationDataPathNoAssets() + "/Python/Run.bat";
         Application.OpenURL(path);
     });
     AddSpace();
     DrawZhongJie();
     DrawZero();
     DrawFirst();
     DrawWhile();
     DrawList();
     DrawDef();
     DrawString();
     DrawSix();
 }
Ejemplo n.º 6
0
    /// <summary>
    /// 返回当前项目中的所有场景配置
    /// </summary>
    public static List <SMSceneConfigurationBase> FindConfigurations()
    {
        List <SMSceneConfigurationBase> allConfigurations = new List <SMSceneConfigurationBase>();

        string[] assetFullPaths = Directory.GetFiles(Application.dataPath, "*.asset", SearchOption.AllDirectories);

        foreach (string fullPath in assetFullPaths)
        {
            string assetPath = MyAssetUtil.GetAssetsBackPath(fullPath);
            SMSceneConfigurationBase configuration = AssetDatabase.LoadAssetAtPath(assetPath, typeof(SMSceneConfigurationBase)) as SMSceneConfigurationBase;
            if (configuration != null)
            {
                allConfigurations.Add(configuration);
            }
        }
        return(allConfigurations);
    }
Ejemplo n.º 7
0
        /// <summary>
        /// 在 _EditorUtil 文件夹下找图片或者GUISkin
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="fileName">文件名 如:</param>
        /// <returns></returns>
        public static T FindTextureOrGUISkin <T>(string fileName)
            where T : Object
        {
            if (null == m_EidtorUtilPaths)
            {
                m_EidtorUtilPaths = Directory.GetDirectories(Application.dataPath, EditorUtil, SearchOption.AllDirectories);
            }

            if (m_EidtorUtilPaths.Length == 0)                   // 还是为空的情况
            {
                MyLog.Red("没有找到 _EditorUtil 的文件夹");
                return(null);
            }
            string fileFullPath = "";

            foreach (string editorUtilPath in m_EidtorUtilPaths)
            {
                string[] fileFullPaths = Directory.GetFiles(editorUtilPath, fileName, SearchOption.AllDirectories);
                if (fileFullPaths.Length == 1)
                {
                    fileFullPath = fileFullPaths[0];
                    break;
                }
                if (fileFullPaths.Length > 1)
                {
                    MyLog.Yellow("有多个相同名字的文件 —— " + fileName);
                }
            }

            if (string.IsNullOrEmpty(fileFullPath))
            {
                MyLog.Red("没有找到这个文件 —— " + fileName);
                return(null);
            }
            string assetPath = MyAssetUtil.GetAssetsBackPath(fileFullPath);

            return(AssetDatabase.LoadMainAssetAtPath(assetPath) as T);
        }
Ejemplo n.º 8
0
    private void AddTu()
    {
        l_Sprites.Clear();
        // 一般的动画图片都是放在一起,而且还是前缀相同的
        Sprite sp = Target.sprite;
        if (null == Target || null == sp)
        {
            MyLog.Red("先添加一个图片在 Image 上啊");
            return;
        }
        // 图片名:abc_01,abc_02,abc_03
        int lastIndex = sp.name.LastIndexOf("_", StringComparison.Ordinal);
        // 找到 abc_
        string sameName = sp.name.Substring(0, lastIndex+1);

        // Assets/GameAssets/_Sprite/Holo Atlas.png
        string aasetpath = AssetDatabase.GetAssetPath(sp);

        // 这个是加载图集中的
        Object[] objs = AssetDatabase.LoadAllAssetsAtPath(aasetpath);
        foreach (Object o in objs)
        {
            if (o.name.Contains(sameName))
            {
                Sprite spo = o as Sprite;
                if (null != spo)
                {
                    l_Sprites.Add(spo);
                }
            }
        }
        if (l_Sprites.Count > 1)       
        {
            return;

        }
        l_Sprites.Clear();
        // 表示还没有找到,那就在它的文件夹下面找
        lastIndex = aasetpath.LastIndexOf("/", StringComparison.Ordinal);
        string directionPath = aasetpath.Substring(0, lastIndex);

        string[] files = Directory.GetFiles(directionPath);

        foreach (string fileFullPath in files)
        {
            string fileName = MyAssetUtil.GetFileNameByFullName(fileFullPath);
            if (fileName.Contains(sameName) && !fileName.Contains(".meta"))
            {
                string assetPath = MyAssetUtil.GetAssetsBackPath(fileFullPath);
                Sprite objSp = AssetDatabase.LoadAssetAtPath<Sprite>(assetPath);
                l_Sprites.Add(objSp);
            }
        }


        /*        // 找到这个图片的 Asset 路径   
          

                // 找到目录路径
              
          
                Object[] objs = AssetDatabase.LoadAllAssetsAtPath(directionPath+"/");

                foreach (Object o in objs)
                {
                    MyLog.Red(o.name);
                }*/



    }