工作中有用的封装好的代码
文章平均质量分 79
qq_1769441047
Unity开发
展开
-
字符串拼接优化
using System.Collections;using System.Collections.Generic;using System.Text;using UnityEngine;public class CSStringBuilder{ public static CSStringBuilder CS { get; set; } = new CSStringBuilder(); public StringBuilder sb = new StringBuilder(10原创 2020-11-12 15:13:56 · 118 阅读 · 0 评论 -
事件管理
using System.Collections;using System.Collections.Generic;using UnityEngine;public class BaseEvent{ //委托 public delegate void CallBack(uint id, params object[] objs); //事件集合 Dictionary<uint, EventHandler> eventDic = new Dictionar原创 2020-11-12 14:49:08 · 99 阅读 · 0 评论 -
shaderUI特效,图片表面显示光柱(主要用于UI按钮简单特效)
Shader "FlowLight"{ Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _FlashColor ("Flash Color", Color) = (1,1,1,1) _Angle ("Flash Angle", Range(0, 180)) = 45 _W...原创 2019-09-02 13:42:41 · 894 阅读 · 0 评论 -
Shader 使图片围绕自己中心旋转(主要是用于旋转的loading界面)
Shader "LoadingImage"{ Properties { _MainTex ("Texture", 2D) = "white" {} _Speed ("Speed",float) = 2 } SubShader { // No culling or depth //Cull Off ZWrite Off ZTest Always T...原创 2019-09-02 13:33:31 · 935 阅读 · 0 评论 -
修改文件名字(这里只是将文件夹的名字添加到文件中,只适用于编辑器模式下)
项目中需要大量修改名字,网上大部分代码都是通过File.Move()函数修改,在实际运用的时候总是报各种IO异常,所以利用了另外一种方法原理:先通过字符拼接生成新名字的文件,再将原文件的数据写入到新文件中,然后再删除新文件,可以达到修改文件名的目的说明:string s = fl.Replace(@"\", "/"); string d= dir.Replace(@"\", "/");这两段代...原创 2019-07-11 18:03:05 · 809 阅读 · 0 评论 -
通过输入ab包名和后缀名自动添加或修改ab包名(同一文件夹下的所有文夹都会被修改包括子文件夹)
using System.Collections;using System.Collections.Generic;using System.IO;using UnityEditor;using UnityEngine;public class SetGoAssertBundleName : EditorWindow { //文件夹名字 string DictorNa...原创 2019-07-10 17:08:04 · 1516 阅读 · 1 评论 -
棋牌类游戏利用字节表示卡牌(仅扑克牌)
#region 成员变量和枚举 public enum CardType { None = 0, WuShiK = 1, Single = 2, Double = 3, Three = 4, Boom = 5, KingBoom = 6, King ...转载 2019-03-06 17:44:09 · 1023 阅读 · 0 评论 -
unity资源管理帮助
public class ABInfo : Component{ private int refCount; public string Name { get; } public int RefCount { get { return this.refCount; } set { //Log.Debug($"{this.Name} refcount: {...转载 2019-03-06 17:36:52 · 257 阅读 · 0 评论 -
时间类(unix)(Timer)(c#)
public static class Timer{ public static long Seconds() { return DateTimeOffset.Now.ToUnixTimeSeconds(); } public static long Milliseconds() { return DateTime...原创 2019-03-06 17:18:53 · 370 阅读 · 0 评论 -
unity编译器打包类(BuildEditor)
public class BundleInfo{ public List<string> ParentPaths = new List<string>();}public enum PlatformType{ None, Android, IOS, PC, MacOS,}public enum BuildType{ Development,...原创 2019-03-06 17:05:46 · 1581 阅读 · 0 评论 -
unity打包帮助类(BuildHelper)(c#)
public static class BuildHelper{private const string relativeDirPrefix = “…/Release”;public static string BuildFolder = “…/Release/{0}/StreamingAssets/”; public static void Build(PlatformType type...原创 2019-03-06 16:59:55 · 419 阅读 · 0 评论 -
unity编译器资源帮助类(EditorResHelper)(c#)
FileHelper为博客中另一个文件帮助类public class EditorResHelper{/// /// 获取文件夹内所有的预制跟场景路径/// /// 源文件夹/// 是否获取子文件夹/// public static List GetPrefabsAndScenes(string srcPath){List paths = new List();F...原创 2019-03-06 16:51:55 · 365 阅读 · 0 评论 -
文件帮助类(FileHelper)(c#)
public static class FileHelper{//得到目录下所有的文件public static void GetAllFiles(List files, string dir){string[] fls = Directory.GetFiles(dir);foreach (string fl in fls){files.Add(fl);}string[] su...转载 2019-03-06 16:39:18 · 1312 阅读 · 0 评论 -
文件md5值的获取(MD5Helper)(c#)
获取文件md5的值public static string FileMD5(string filePath) { byte[] retVal; using (FileStream file = new FileStream(filePath, FileMode.Open)) { MD5 md5 = new MD5CryptoServiceP...原创 2019-03-06 16:40:21 · 602 阅读 · 0 评论