#Anyone had much luck with NuGetForUnity + Roslyn Runtime scripting?

1 messages · Page 1 of 1 (latest)

wanton gazelle
#

After a few starter projects, I'm starting on my first bigger piece of work - a roguelike CCG.
For card behaviour scripts, I'm wanting to stick with C# if possible, so have used a combo of the NuGetForUnity upm package and the CSharpScripting package, giving runtime C# compilation with the Roslyn compiler.

The basic setup works, but I've run into two issues:

  • If I run the script with "EvaluateAsync", it's slow, and runs into an issue I've seen online with non-Unity users where it essentially loads single-use assemblies into the game, leading to memory leak issues. Not great
  • If I run using the "Create", "Compile" and "RunAsync" commands, it seems to keep hold of the Assembly-CSharp.dll between Unity runs, so I need to close the editor every time I change the code. Presumably won't be good for packaged-up version of the game.

So I guess I have a few questions based on this:

  • Does this approach work, and if so how to solve the issue?
  • If not, what are the best (free + license free) alternatives? Any that still use C#, or go to Lua/JS etc.?
  • Is NuGetForUnity work using at all? I'm a full time C# dev so it was pretty appealing but don't know it's reliability
charred scaffold
#

I cannot help you with your exact issues, I just want to suggest this video to you: https://www.youtube.com/watch?v=dY6jR52fFWo

Attempting to create a little game where programming is the core mechanic.

Links:
Compile C# at runtime: https://github.com/SebLague/Runtime-CSharp-Test
Project source (warning, total mess!): https://github.com/SebLague/Coding-Game
CRT effect - https://www.shadertoy.com/view/Ms23DR

If you'd like to support the creation of more programming vide...

▶ Play video
wanton gazelle
#

Thanks for the suggestion, though I’d probably go interpreted before rolling my own language

charred scaffold
#

sorry, should have explained further

wanton gazelle
#

Ah right, you mean the CodeDom API rather than Roslyn. CodeDom is pretty dated, and from what I've looked into it doesn't support quite a few common language features or platforms.

charred scaffold
wanton gazelle
#

Yeah, nothing seems to be recently updated in this area.
For now I've started trying out Jint (JS interpreter). Seems to be pretty feature complete, and still active.

charred scaffold
#

what are you trying to achieve btw? is it user generated code or do you just want to execute code that each card inherintly has?

wanton gazelle
#

The inherent card code. Could put everything pre-compiled, but that doesn't seem particularly scaleable

nocturne meteor
#

and do you imagine the game to work like Slay the Spire or something

wanton gazelle
#

Yeah, pretty much like StS

nocturne meteor
#

roslyn runtime scripting isn't really ready for prime time

#

i mean nobody uses it

wanton gazelle
#

That's a shame. It's been around a few years so I was hopeful 🙁

nocturne meteor
#

nuget for unity works fine but it's a lift to understand how to use it and to get everything working correctly on ios

wanton gazelle
#

For getting nugetforunity working on ios, or unity code in general?

nocturne meteor
#

what's your big picture goal? why runtime script at all?

nocturne meteor
#

slay the spire doesn't use scripting. the cards are just java

#

have you read the XMage source?

#

i mean, when it was written. i don't know how the Unity version works now

wanton gazelle
wanton gazelle
nocturne meteor
#

have you written any cards

#

start of a long journey

wanton gazelle
#

A few basic ones so far. Move, ranged attack. Was mostly working on the player turn setup til now. Card position in hand, state management, grid pathfinding etc.

#

(it's grid based)

nocturne meteor
#

have you played duelyst?

wanton gazelle
#

Name rings a bell, not played though

#

Closest games to what I'm aiming for are Fights in tight spaces or Metal gear acid

nocturne meteor
#

do you have a family? like do you have time?

#

lol

wanton gazelle
#

Much less time than I'd like 😄 but no life-consuming commitments other than work

nocturne meteor
#

what's the most exciting part of this? the engineering? the art? for example

wanton gazelle
#

Engineering mostly, but also hitting playable milestones

#

I assume this is gearing towards a "better to spend your time on XYZ" kind of statement?

nocturne meteor
#

no

#

lol

#

generally i like to say positive stuff about making games this isn't hacker news

#

within unity specifically, HPC# aka c# in unity with the burst annotations and types is a really interesting simulation feature and unique to the platform

#

so if you were interesting in making a bot that works really well, for example, there's a lot of unique features there

#

and for art obviously it's very capable

#

lots of unique opportunities there

#

it's harder for dynamic scripting because iOS fundamentally does not want you to do that

#

it's not very impactful for card games, but it would be if you had a bot that plays out matches

#

everyone who wants dynamic scripting in a card game makes a client-server architecture

#

basically doing any of these things well/correctly wrt how you engineer the cards only really pays off one way: better bots

#

which is why there are basically no card games with good AI opponents

wanton gazelle
#

Yeah, that's definitely something I was planning towards

#

And a huge peeve of mine in when single player games need online connection, so really want to avoid server-based bots

#

If ios is the only real blocker to that, I'd rather just avoid the platform

charred scaffold
wanton gazelle
#

Still meaning for ios, or just as a general practice?

nocturne meteor
#

i would say dynamic scripting is a huge distraction

#

generally the only mature dynamic scripting solution for most games uses lua, because the engine for it is designed to be embedded in applications, it's the only compliant engine besides luajit, and the thing that actually matters for this stuff from an engineering/performance pov is arena allocation

#

python is a much bigger lift to do

#

i personally dislike DSLs

#

i make a card game

wanton gazelle
#

maybe so

#

not sure why I've got it in my head that using a DSL is "correct" for this kind of thing

nocturne meteor
#

python would be better because you just want the chatbots to author this anyway

#

from card text to code

charred scaffold