Esempio n. 1
0
        protected void AddGradient(MyJson_Tree gradientItem, string key, Gradient gradient)
        {
            //alpha和color过渡值最大为4,如果不够手动填充,如果超过,中间的截掉
            GradientAlphaKey[] alphaKeys = this.FillGradientAlpha(gradient);
            GradientColorKey[] colorKeys = this.FillGradientColor(gradient);

            MyJson_Tree gradients = new MyJson_Tree(false);

            gradients.SetEnum("mode", gradient.mode);
            var alphaKeysItem = new MyJson_Array();
            var colorKeysItem = new MyJson_Array();

            gradients["alphaKeys"] = alphaKeysItem;
            gradients["colorKeys"] = colorKeysItem;

            //alphaKey
            foreach (GradientAlphaKey _ak in alphaKeys)
            {
                MyJson_Tree akItem = new MyJson_Tree(false);
                int         akHash = akItem.GetHashCode();
                akItem.SetNumber("alpha", _ak.alpha);
                akItem.SetNumber("time", _ak.time);
                alphaKeysItem.Add(akItem);
            }

            //colorKey
            foreach (GradientColorKey _ck in colorKeys)
            {
                MyJson_Tree ckItem = new MyJson_Tree(false);
                int         ckHash = ckItem.GetHashCode();
                ckItem.SetColor("color", _ck.color);
                ckItem.SetNumber("time", _ck.time);
                colorKeysItem.Add(ckItem);
            }

            gradientItem[key] = gradients;
        }