You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let me present an example. I'm doing something like this: engine.SetValue("model", team)
Now a team contains units, i.e. in C# it's:
public interface IModel
{
int teamId { get; } // team id
IReadOnlyList<IUnitControl> myUnits { get; }
IReadOnlyList<IUnit> enemyUnits { get; }
}
Now here's what I'm trying to achieve - if a unit belongs to the team then it's api contains control methods like Move(), Attack() etc. But it it's a unit of another team, then only read-only methods and properties are available, like GetPosition(). In C# units implement two interfaces - IUnit and IUnitControl. But when I expose units to javascript all control methods are available even for enemy units.
Is there a way I could customize which methods of a C# object get exposed to javascript?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Let me present an example. I'm doing something like this:
engine.SetValue("model", team)
Now a team contains units, i.e. in C# it's:
Now here's what I'm trying to achieve - if a unit belongs to the team then it's api contains control methods like Move(), Attack() etc. But it it's a unit of another team, then only read-only methods and properties are available, like GetPosition(). In C# units implement two interfaces - IUnit and IUnitControl. But when I expose units to javascript all control methods are available even for enemy units.
Is there a way I could customize which methods of a C# object get exposed to javascript?
Beta Was this translation helpful? Give feedback.
All reactions