Mod_Color.cs(55,55):错误CS0241:不允许使用默认参数说明符(CS0241)(Assembly-CSharp)

时间:2015-07-07 18:38:01

标签: c# unity3d compilation

尝试在C#中编译时遇到此错误(在monodevelop unity中) 请告诉我如何解决它

Mod_Color.cs(55,55): Error CS0241: Default parameter specifiers are not permitted (CS0241) (Assembly-CSharp)

代码:

namespace TestHack.RENDER
{
    using System;
    using System.Runtime.InteropServices;
    using UnityEngine;

    public class Mod_Color
    {
        private Color color;

        public Mod_Color(float r, float g, float b, float a = 255f)
        {
            this.color = new Color(r / 255f, g / 255f, b / 255f, a / 255f);
        }

        public Color Get()
        {
            return this.color;
        }
    }
}

1 个答案:

答案 0 :(得分:0)

使用两个重载:

public class Mod_Color
{
    private Color color;

    public Mod_Color(float r, float g, float b)
    {
        this.color = Mod_Color(r, g, b, 255f);
    }

    public Mod_Color(float r, float g, float b, float a)
    {
        this.color = new Color(r / 255f, g / 255f, b / 255f, a / 255f);
    }

    public Color Get()
    {
        return this.color;
    }
}

您似乎正在使用不支持默认参数说明符的.NET框架或Mono框架。使用重载的方式相同,无需修改现有代码。