Пример #1
0
    public void TestCaseFormatColor()
    {
        ColorPresets.Reflash();
        int count = ColorPresets.Count();

        string[] keys = ColorPresets.GetColorKeys();
        if (keys == null)
        {
            return;
        }

        string format  = "[#{0}]asdfsdfsdf111[-]";
        string format2 = "[{0}]asdfsdfsdf111[-]";

        for (int i = 0; i < count; ++i)
        {
            string key   = keys[i];
            string num   = key.Remove(0, ColorPresets.COLOR_PREFIX.Length);
            string value = ColorPresets.GetHexString(key);

            string lhs = ColorPresets.FormatText(string.Format(format, num));
            string rhs = string.Format(format2, value);
            Assert.AreEqual(lhs, rhs);
        }
    }
Пример #2
0
    private static void PrintColorPresets()
    {
        if (EditorApplication.isCompiling)
        {
            EditorUtility.DisplayDialog("提示", "编译完再试喔", "Ok");
            return;
        }

        ColorPresets.Reflash();
        int count = ColorPresets.Count();

        string[] keys = ColorPresets.GetColorKeys();
        if (keys == null)
        {
            return;
        }

        string ret = "";

        for (int i = 0; i < count; ++i)
        {
            string key   = keys[i];
            string value = ColorPresets.GetHexString(key);
            ret += string.Format("{0} {1}\n", key, value);
        }

        Debug.Log(ret);
    }