Example #1
0
 public static string GetTextMeshNameColor(string color, string name)
 {
     //"<color=#48b4f2>" + name + "</color>"
     color = EZFunTools.EZSubString(color, 1, 6);
     //        color = EZFunString.LinkString("#", color);
     return(EZFunString.LinkString("<color=", color, ">", name + "</color>"));
 }
Example #2
0
    public static Shader FindShader(string shaderName)
    {
        Shader shader        = null;
        bool   existsInCache = File.Exists(CachePath + "/Table/shader.json");

        //persist 和 cache目录file.exists可以工作 Application.streamingAssetsPath不行 会一直返回false
        //if (m_shaderDic.Count == 0 && (existsInCache || File.Exists(Application.streamingAssetsPath + "/Table/shader.json")))
        {
            byte[] bytes = null;
            if (existsInCache)
            {
                bytes = EZFunTools.ReadFile(CachePath + "/Table/shader.json");
            }
            else
            {
                bytes = EZFunTools.ReadFile(Application.streamingAssetsPath + "/Table/shader.json");
            }
            var str  = System.Text.Encoding.Default.GetString(bytes);
            var json = JsonMapper.ToObject(str)["shaders"];
            if (json.IsArray)
            {
                for (int i = 0; i < json.Count; i++)
                {
                    var entry = json[i];
                    var name  = (string)entry["name"];
                    var path  = (string)entry["path"];
                    if (!m_shaderDic.ContainsKey(name))
                    {
                        m_shaderDic.Add(name, path);
                    }
                }
            }
        }
        if (m_shaderDic.ContainsKey(shaderName) && Application.isPlaying)
        {
            shader = ResourceManager.Instance.LoadResource(m_shaderDic[shaderName], typeof(Shader)) as Shader;
        }
        else
        {
            shader = Shader.Find(shaderName);
        }
        return(shader);
    }
Example #3
0
    public static string getFileHash(string fileName)
    {
        try
        {
            var    path = EZFunTools.GetResPath(UpdateType.MapFile, fileName);
            byte[] data = ReadFile(path);

            MD5    md5     = new MD5CryptoServiceProvider();
            byte[] result  = md5.ComputeHash(data);
            string fileMD5 = "";
            foreach (byte b in result)
            {
                fileMD5 += Convert.ToString((b >> 4) & 0xf, 16);
                fileMD5 += Convert.ToString(b & 0xf, 16);
            }
            return(fileMD5);
        }
        catch (FileNotFoundException e)
        {
            Console.WriteLine(e.Message);
            return("");
        }
    }
Example #4
0
    // 计算unix时间格式的时间
    public static string GetTimeStr(long time)
    {
        var interval = EZFunTools.GetTimeInterval(time);

        return(GetTimeStrHour(interval));
    }