我得到这个错误,而试图在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;
}
}
}
使用两个重载:
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框架,不支持默认参数说明符。使用重载的工作方式相同,无需修改现有代码。