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
は+=
または-=
演算子の左側にのみ表示できますその同じエラーが何度も何度も。私はネットで検索しました、そしてこのエラーについて多くの説明があります、しかし私は正しいものを見つけることができないようです。または私はちょうど非常に悪い日を過ごしています:)
私を助けてください
あなたが宣言したからですadd
とremove
、あなたのコードを動作させるために、あなたはちょうどあなたが使用するときのように(プライベート)バッキングフィールドを宣言する必要がありget
、および/またはset
、その後、あなたは、このプライベートフィールドを使用して呼び出すことができます。
だからあなたはこのようなものを持っているはずです
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;
private static event PushToGridEventHandler _pushToGridEvent;
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)
{
_pushToGridEvent?.Invoke(snapValue);
}
}
public delegate void PushToGridEventHandler(float snapValue);
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加