コード例 #1
0
    public static void DoMatAndPng(string rootName, string path)
    {
        string        assetPath = TCommon.RemovePathPrefix(path);
        Material      m         = AssetDatabase.LoadAssetAtPath <Material>(assetPath);
        MatData       data      = MatTool.MatToJson(m);
        string        jsonData  = JsonMapper.ToJson(data);
        StringBuilder sb        = new StringBuilder();
        JsonWriter    write     = new JsonWriter(sb);

        JsonMapper.ToJson(data, write);
        int    idx      = path.LastIndexOf('\\');
        string paraPath = path.Substring(0, idx);

        Debug.Log("paraPath:" + paraPath);
        paraPath = paraPath + "\\mat.json";
        File.WriteAllText(paraPath, sb.ToString());
        //对mat_json文件标记ab
        AssetImporter importer = AssetImporter.GetAtPath(TCommon.RemovePathPrefix(paraPath));

        importer.assetBundleName    = $"{rootName}_mat";
        importer.assetBundleVariant = TCommon.ABSUFFIX;

        AssetImporter importerTex = AssetImporter.GetAtPath(data.attributes[0].texAttri.Item3.bundleDir);

        importerTex.assetBundleName    = $"{rootName}_png";
        importerTex.assetBundleVariant = TCommon.ABSUFFIX;
    }
コード例 #2
0
ファイル: Load.cs プロジェクト: LiZhiMeng/UnityStudy
    public GameObject LoadModel(string modelName)
    {
        //加载图片
        string      pngPath = $"{Application.streamingAssetsPath}/model/{modelName}_png{TCommon.ABSUFFIX_AFTER}";
        string      fbxPath = $"{Application.streamingAssetsPath}/model/{modelName}_base{TCommon.ABSUFFIX_AFTER}";
        AssetBundle ab_png  = AssetBundle.LoadFromFile(TCommon.RemovePathPrefix(pngPath));
        Texture2D   png     = ab_png.LoadAsset <Texture2D>("city02_beauty");

        //加载材质球json
        string      jsonPath  = $"{Application.streamingAssetsPath}/model/{modelName}_mat{TCommon.ABSUFFIX_AFTER}";
        AssetBundle ab_json   = AssetBundle.LoadFromFile(jsonPath);
        TextAsset   textAsset = ab_json.LoadAsset <TextAsset>("mat");
        MatData     matData   = new MatData();

        matData = JsonMapper.ToObject <MatData>(textAsset.text);
        Shader shader = new Shader();

        shader = Shader.Find(matData.shader);
        Material mat = new Material(shader);

        mat.mainTexture = png;
        Debug.Log("aa:" + matData.shader);

        //加载fbx
        AssetBundle  fbx_ab = AssetBundle.LoadFromFile(TCommon.RemovePathPrefix(fbxPath));
        GameObject   prefab = fbx_ab.LoadAsset <GameObject>(modelName);
        GameObject   model  = GameObject.Instantiate(prefab);
        MeshRenderer render = model.GetComponent <MeshRenderer>();

        render.material = mat;
        return(model);
    }
コード例 #3
0
    private void OnGUI()
    {
        string [] dirs = Directory.GetDirectories(inAtlasPath);
        for (int i = 0; i < dirs.Length; i++)
        {
            string   dirPath      = dirs[i];
            string[] splitDirPath = dirPath.Split('\\');
            string   atlasName    = splitDirPath[splitDirPath.Length - 1];

            if (GUILayout.Button(atlasName))
            {
                Debug.Log($"Build{atlasName}");
                EditorUtility.DisplayProgressBar("Building", $"Building:{TCommon._atlas}", 0.5f);
                string prefabPath = $"{dirPath}/{atlasName}.prefab";
                TCommon.GetNewAssetVersion(prefabPath);
                TCommon.GetOldAssetVersion(TCommon._atlas);
                if (TCommon.IsNeedPak(prefabPath))
                {
                    Build(dirPath, atlasName);
                }
                TCommon.SaveAssetVersion(TCommon._atlas);
                AssetDatabase.Refresh();
                EditorUtility.ClearProgressBar();
            }
        }
    }
コード例 #4
0
ファイル: TCommon.cs プロジェクト: LiZhiMeng/UnityStudy
    /// <summary>
    /// 拿到新资源的版本
    /// </summary>
    public static void GetNewAssetVersion(string path)
    {
        newVersion.Clear();
        string md5Data = TCommon.ComputeMD5(path);

        newVersion.Add(GetAssetPath(path), md5Data);
    }
コード例 #5
0
ファイル: BuildTool.cs プロジェクト: LiZhiMeng/UnityStudy
    public static void BuildModel()
    {
        Debug.Log("build Model");
        string type = TCommon._model;

        ClearAB();
        BuildBundleModel.MarkAB(Application.dataPath + TCommon.ModelBuildPath);
        BuildBundle(TCommon.GetBundlePathFromType(type));
        DeleteManifest();
        ClearAB();
        AssetDatabase.Refresh();
    }
コード例 #6
0
    public static void DoFbx(string rootName, string fbxPath)
    {
        GameObject fbxGo      = AssetDatabase.LoadAssetAtPath <GameObject>(TCommon.RemovePathPrefix(fbxPath));
        GameObject instanGo   = GameObject.Instantiate(fbxGo);
        string     prefabPath = fbxPath.Substring(0, fbxPath.LastIndexOf('\\'));

        prefabPath = $"{prefabPath}\\{rootName}.prefab";
        prefabPath = prefabPath.Replace("\\", "/");
        Object        newPrefab   = PrefabUtility.CreateEmptyPrefab(TCommon.RemovePathPrefix(prefabPath));
        GameObject    finalPrefab = PrefabUtility.ReplacePrefab(instanGo, newPrefab);
        string        finalPath   = AssetDatabase.GetAssetPath(finalPrefab);
        AssetImporter importer    = AssetImporter.GetAtPath(finalPath);

        importer.assetBundleName    = $"{rootName}_base";
        importer.assetBundleVariant = TCommon.ABSUFFIX;
    }
コード例 #7
0
ファイル: BuildTool.cs プロジェクト: LiZhiMeng/UnityStudy
    public static void BuildIcon()
    {
        Debug.Log("Menu: BuildIcon");
        ClearAB();

        string        buildPath = Application.dataPath + TCommon.IconBuildPath;
        List <string> suffix    = new List <string>();

        suffix.Add(".png");
        SearchFileNeedBuild(buildPath, suffix);
        string type = TCommon._icon;

        BuildBundle(TCommon.GetBundlePathFromType(type));
        DeleteManifest();
        ClearAB();
    }
コード例 #8
0
ファイル: BuildTool.cs プロジェクト: LiZhiMeng/UnityStudy
    public static void BuildFont()
    {
        Debug.Log("Menu: BuildFont");

        string type = TCommon._font;

        ClearAB();
        List <string> suff = new List <string>();

        suff.Add("otf");
        suff.Add("ttf");
        SearchFileNeedBuild(Application.dataPath + TCommon.FontBuildInPath, suff);
        BuildBundle(TCommon.GetBundlePathFromType(type));
        DeleteManifest();
        ClearAB();
        AssetDatabase.Refresh();
    }
コード例 #9
0
 public void Init <T>(T defaultValue, Action <int> OnClick)
 {
     m_Text.text = defaultValue.ToString();
     m_ChunkButton.Clear();
     TCommon.TraversalEnum((T temp) =>
     {
         int index  = (int)((object)temp);
         Button btn = m_ChunkButton.AddItem(index);
         btn.onClick.RemoveAllListeners();
         btn.GetComponentInChildren <Text>().text = temp.ToString();
         btn.onClick.AddListener(() => {
             m_Text.text = temp.ToString();
             OnClick(index);
             m_ChunkButton.transform.SetActivate(false);
         });
     });
 }
コード例 #10
0
ファイル: BuildTool.cs プロジェクト: LiZhiMeng/UnityStudy
    // [MenuItem("Assets/BuildSound &2", false)]
    public static void BuildSound()
    {
        Debug.Log("Menu: Build Sound");
        ClearAB();

        string        type   = TCommon._sound;
        List <string> suffix = new List <string>();

        suffix.Add(".mp3");
        string buildPath = TCommon.SoundBuildInPath;

        SearchFileNeedBuild(Application.dataPath + buildPath, suffix);
        BuildBundle(TCommon.GetBundlePathFromType(type));
        DeleteManifest();
        ClearAB();
        AssetDatabase.Refresh();
    }
コード例 #11
0
ファイル: BuildTool.cs プロジェクト: LiZhiMeng/UnityStudy
    /// <summary>
    /// 删除manifest
    /// </summary>
    public static void DeleteManifest()
    {
        TCommon._streamingAssetFileList.Clear();
        TCommon.GetList(Application.streamingAssetsPath);
        foreach (var curFile in TCommon._streamingAssetFileList)
        {
            if (File.Exists(curFile))
            {
                Debug.Log("file2:" + curFile);
                File.Delete(curFile);
            }
        }

        Debug.Log("删除manifest完成");
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
コード例 #12
0
ファイル: TPhysics.cs プロジェクト: striter/VDefend
        public ParacurveBouncePSimulator(Transform _transform, Vector3 _startPos, Vector3 _endPos, float _angle, float _horiSpeed, float _height, float _radius, bool randomRotation, int _hitLayer, bool bounce, float _bounceSpeedMultiply, Func <RaycastHit, T, bool> _onBounceHit, Predicate <T> _OnBounceCheck) : base(_transform, _startPos, Vector3.zero, _height, _radius, _hitLayer, _onBounceHit, _OnBounceCheck)
        {
            Vector3 horiDirection = TCommon.GetXZLookDirection(_startPos, _endPos);
            Vector3 horiRight     = horiDirection.RotateDirection(Vector3.up, 90);

            m_Direction = horiDirection.RotateDirection(horiRight, -_angle);
            f_speed     = _horiSpeed / Mathf.Cos(_angle * Mathf.Deg2Rad);
            float horiDistance  = Vector3.Distance(_startPos, _endPos);
            float duration      = horiDistance / _horiSpeed;
            float vertiDistance = Mathf.Tan(_angle * Mathf.Deg2Rad) * horiDistance;

            f_vertiAcceleration   = Expressions.GetAcceleration(0, vertiDistance, duration);
            b_randomRotation      = randomRotation;
            b_bounceOnHit         = bounce;
            f_bounceSpeedMultiply = _bounceSpeedMultiply;
            v3_RotateEuler        = Quaternion.LookRotation(m_Direction).eulerAngles;
            v3_RotateDirection    = new Vector3(UnityEngine.Random.Range(-1f, 1f), UnityEngine.Random.Range(-1f, 1f));
        }
コード例 #13
0
    public static void MarkByOne(string path)
    {
        //取得文件路径
        List <string> fileList = new List <string>();

        TCommon.GetList(path, ref fileList);
        string pngPath    = "";
        string matPath    = "";
        string fbxPath    = "";
        string prefabPath = "";

        foreach (var cur_path in fileList)
        {
            if (cur_path.Contains(".meta"))
            {
                continue;
            }
            if (cur_path.ToLower().Contains(".fbx"))
            {
                fbxPath = cur_path;
            }

            if (cur_path.ToLower().Contains(".mat"))
            {
                matPath = cur_path;
            }

            if (cur_path.Contains(".prefab"))
            {
                prefabPath = cur_path;
            }
        }

        string rootName = path.Substring(path.LastIndexOf('\\') + 1);

        DoMatAndPng(rootName, matPath);
        DoFbx(rootName, fbxPath);
    }
コード例 #14
0
ファイル: Kayle.cs プロジェクト: q51251/Tc_SDKexAIO
        private static void OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
        {
            if (!R.IsReady() || sender.IsMinion || !sender.IsEnemy || args.SData.ConsideredAsAutoAttack ||
                !Menu["R"]["AutoR"].GetValue <MenuBool>() || !sender.IsValid || args.SData.Name.ToLower() == "tormentedsoil")
            {
                return;
            }

            if (Menu["R"]["Spell" + args.SData.Name] == null || !Menu["R"]["Spell" + args.SData.Name].GetValue <MenuBool>())
            {
                return;
            }

            if (args.Target != null)
            {
                if (args.Target.IsAlly)
                {
                    var ally = args.Target as Obj_AI_Hero;

                    if (ally != null && Menu["R"]["Rally" + ally.ChampionName].GetValue <MenuBool>())
                    {
                        R.CastOnUnit(ally);
                    }
                }
                else
                {
                    foreach (var ally in PlaySharp.Allies.Where(ally => ally.IsValid && !ally.IsDead && ally.HealthPercent < 70 &&
                                                                Player.ServerPosition.Distance(ally.ServerPosition) < R.Range && Menu["R"]["Rally" + ally.ChampionName].GetValue <MenuBool>()))
                    {
                        if (TCommon.CanHitSkillShot(ally, args))
                        {
                            R.CastOnUnit(ally);
                        }
                    }
                }
            }
        }
コード例 #15
0
    public void Build(string dirPath, string atlasName)
    {
        TCommon.DeleteOutPutDir(TCommon._atlas);
        BuildTool.ClearAB();
        string prefabPath = $"{inAtlasPath}/{atlasName}/{atlasName}.prefab";

        prefabPath = TCommon.RemovePathPrefix(prefabPath);
        string pngPath = $"{inAtlasPath}/{atlasName}/{atlasName}.png";

        pngPath = TCommon.RemovePathPrefix(pngPath);
        Debug.Log(TCommon.RemovePathPrefix(prefabPath));
        AssetImporter importerPrefab = AssetImporter.GetAtPath(prefabPath);

        importerPrefab.assetBundleName    = atlasName;
        importerPrefab.assetBundleVariant = TCommon.ABSUFFIX;
        AssetImporter importerPng = AssetImporter.GetAtPath(pngPath);

        importerPng.assetBundleName    = atlasName;
        importerPng.assetBundleVariant = TCommon.ABSUFFIX;
        BuildTool.BuildBundle(outAtlasPath);
        BuildTool.ClearAB();
        BuildTool.DeleteManifest();
        AssetDatabase.Refresh();
    }
コード例 #16
0
 private void OnEnable()
 {
     inAtlasPath  = Application.dataPath + "/PracticeAssets/Resources/atlas";
     outAtlasPath = Application.streamingAssetsPath + "/atlas";
     outAtlasPath = TCommon.RemovePathPrefix(outAtlasPath);
 }
コード例 #17
0
 public static void Init()
 {
     Clear();
     TCommon.TraversalEnum((TEnum temp) => { dic_delegates.Add(temp, new List <LocalMessage>()); });
 }
コード例 #18
0
 public void AddRecoil(float recoilAmount) => v3_Recoil += new Vector3(0, (TCommon.RandomBool() ? 1 : -1) * recoilAmount, 0);