namespace Rocket.Common
{
using System;
using System.Threading;
public class SharedProperties
{
public static bool snapEnabled = false;
public static float snapValue = 0.25f;
public static bool useAxisConstraints = true;
public static event PushToGridEventHandler PushToGridEvent
{
add
{
PushToGridEventHandler pushToGridEvent = PushToGridEvent;
while (true)
{
PushToGridEventHandler a = pushToGridEvent;
PushToGridEventHandler handler3 = (PushToGridEventHandler) Delegate.Combine(a, value);
pushToGridEvent = Interlocked.CompareExchange(ref PushToGridEvent, handler3, a);
if (ReferenceEquals(pushToGridEvent, a))
{
return;
}
}
}
remove
{
PushToGridEventHandler pushToGridEvent = PushToGridEvent;
while (true)
{
PushToGridEventHandler source = pushToGridEvent;
PushToGridEventHandler handler3 = (PushToGridEventHandler) Delegate.Remove(source, value);
pushToGridEvent = Interlocked.CompareExchange(ref PushToGridEvent, handler3, source);
if (ReferenceEquals(pushToGridEvent, source))
{
return;
}
}
}
}
public static void PushToGrid(float snapValue)
{
if (PushToGridEvent != null)
{
PushToGridEvent(snapValue);
}
}
public delegate void PushToGridEventHandler(float snapValue);
}
}
有人可以帮助我解决这个难题。我似乎无法解决这个错误。
我在以下几行中遇到错误;
Rocket.Common.SharedProperties.PushToGridEvent
仅出现在+=
或-=
运算符的左侧Rocket.Common.SharedProperties.PushToGridEvent
仅出现在+=
或-=
运算符的左侧Rocket.Common.SharedProperties.PushToGridEvent
仅出现在+=
或-=
运算符的左侧Rocket.Common.SharedProperties.PushToGridEvent
仅出现在+=
或-=
运算符的左侧Rocket.Common.SharedProperties.PushToGridEvent
仅出现在+=
或-=
运算符的左侧Rocket.Common.SharedProperties.PushToGridEvent
仅出现在+=
或-=
运算符的左侧一次又一次地出现相同的错误。我已经在网上搜索了很多关于此错误的解释,但我似乎找不到正确的错误。还是我今天过得很糟糕:)
请帮帮我
答案 0 :(得分:0)
这是因为您已经声明了add
和remove
,为了使代码正常工作,您必须声明一个后备字段(私有),就像使用get
和/或{ {1}},然后您就可以使用此私有字段进行调用。
所以你应该有这样的东西
set