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; }
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); }
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(); } } }
/// <summary> /// 拿到新资源的版本 /// </summary> public static void GetNewAssetVersion(string path) { newVersion.Clear(); string md5Data = TCommon.ComputeMD5(path); newVersion.Add(GetAssetPath(path), md5Data); }
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(); }
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; }
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(); }
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(); }
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); }); }); }
// [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(); }
/// <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(); }
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)); }
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); }
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); } } } } }
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(); }
private void OnEnable() { inAtlasPath = Application.dataPath + "/PracticeAssets/Resources/atlas"; outAtlasPath = Application.streamingAssetsPath + "/atlas"; outAtlasPath = TCommon.RemovePathPrefix(outAtlasPath); }
public static void Init() { Clear(); TCommon.TraversalEnum((TEnum temp) => { dic_delegates.Add(temp, new List <LocalMessage>()); }); }
public void AddRecoil(float recoilAmount) => v3_Recoil += new Vector3(0, (TCommon.RandomBool() ? 1 : -1) * recoilAmount, 0);