Exemplo n.º 1
0
    // 加载shader 的接口
    public override void LoadShader(string shaderName, bool async, AssetLoadHook pfun)
    {
        string shaderkey = ResourcesPath.GetAssetResourceRunPath(ResourcesType.Shader, ResourcesPathMode.Editor) + shaderName + ".shader";

        shaderkey = shaderkey.ToLower();
        LoadObj(ResourcesType.Shader, "shader", shaderkey, typeof(Shader), true, true, false, async, pfun);
    }
Exemplo n.º 2
0
    public static bool CreateItem(string ItemName, string BaseItem, bool isLoad = false)
    {
        if (string.IsNullOrEmpty(ItemName) == true)
        {
            return(false);
        }
        string ClassItem = "";

        if (ItemName.EndsWith("Item") == true)
        {
            ClassItem = ItemName;
        }
        else
        {
            ClassItem = ItemName + "Item";
        }

        MakeItem_HCode(ClassItem);
        MakeItemCode(ClassItem, BaseItem);
        AssetDatabase.Refresh();
        EditorUtility.DisplayDialog("提示", "脚本生成完毕", "确定");

        if (isLoad == true)
        {
            string path = ResourcesPath.GetAssetResourceRunPath(ResourcesType.UIWndItem, ResourcesPathMode.Editor);
            path += ClassItem + ".prefab";
            Debug.Log(path);
            //GameObject Prefab = AssetDatabase.LoadAssetAtPath(path, typeof(GameObject)) as GameObject;
            GameObject Prefab = PrefabUtility.LoadPrefabContents(path);
            if (Prefab != null)
            {
                //GameObject go = GameObject.Instantiate(Prefab);
                GameObject go = Prefab;
                if (null != go)
                {
                    go.transform.SetParent(GameObject.Find("UI/Wnd").transform, false);
                    Debug.Log("窗口模本生成完毕");
                }
            }
            else
            {
                Prefab = AssetDatabase.LoadAssetAtPath("Assets/Editor/UITool/XXXItem.prefab", typeof(GameObject)) as GameObject;
                GameObject go = GameObject.Instantiate(Prefab);
                if (null != go)
                {
                    go.transform.SetParent(GameObject.Find("UI/Wnd").transform, false);
                    go.name = ClassItem;
                    //
                    Debug.Log("Item模板生成完毕");
                }
            }
        }
        return(true);
    }
Exemplo n.º 3
0
    /// <summary>
    ///     <para> 设置文件夹下指定后缀资源的ab名,每个资源独立打成一个ab </para>
    /// </summary>
    /// <param name="typename"></param>
    static void ReimportPathUsePathNameWidthResourceType(string typename)
    {
        string inPath = ResourcesPath.GetAssetResourceRunPath(typename, ResourcesPathMode.Editor);

        inPath = inPath.Substring(0, inPath.Length - 1);

        string outPath = ResourcesPath.GetRelativePath(typename, ResourcesPathMode.AssetBundle);

        outPath = outPath.Substring(0, outPath.Length - 1);

        string ext = ResourcesPath.GetFileExt(typename);

        ext = ext.Substring(1);

        ReimportPathUsePathName(inPath, outPath, ext);
    }
Exemplo n.º 4
0
    /// <summary>
    /// 获得所有窗体
    /// </summary>
    /// <returns></returns>
    public static string[] GetAllItem()
    {
        List <string> list       = new List <string>();
        List <string> listPath   = new List <string>();
        string        temp       = ResourcesPath.GetAssetResourceRunPath(ResourcesType.UIWndItem, ResourcesPathMode.Editor);
        string        SearchPath = temp.Substring(0, temp.Length - 1);

        listPath.Add(SearchPath);
        var guid2 = AssetDatabase.FindAssets("t:gameObject", listPath.ToArray());

        foreach (var guid in guid2)
        {
            string assetpath = AssetDatabase.GUIDToAssetPath(guid);
            string name      = Path.GetFileNameWithoutExtension(assetpath);
            if (name.Contains("Item") == true)
            {
                list.Add(name);
            }
        }
        return(list.ToArray());
    }
Exemplo n.º 5
0
    // Lua
    static void ReimportLua()
    {
        string path = ResourcesPath.GetAssetResourceRunPath(ResourcesType.luaData, ResourcesPathMode.Editor);

        path = path.Substring(0, path.Length - 1);

        string tempPath = "Assets/Temp/lua";

        // 先删除旧的临时文件夹
        IGG.FileUtil.DeleteFileDirectory(tempPath);

        // 把所有的lua拷贝到Assets/Temp/lua文件夹下,整个文件夹打成一个lua.ab
        List <string> files = IGG.FileUtil.GetAllChildFiles(path, "lua");

        for (int i = 0; i < files.Count; ++i)
        {
            string pathSrc = files[i];
            string pathDst = pathSrc.Replace(path, tempPath).Replace(".lua", ".bytes");
            IGG.FileUtil.CopyFile(pathSrc, pathDst);
        }
        AssetDatabase.Refresh();

        ReimportPath(tempPath, "lua", "bytes");
    }