Home > Mobile >  Creating scripts like Unity
Creating scripts like Unity

Time:12-21

Currently I am attempting to create an game editor and I'm trying to implement scripting similar to Unity where I can create a C script template and perform coding in it, but I'm not sure how to implement this. What should I use in attempting to implement this?

CodePudding user response:

Unity is so much more than an editor. It's a game engine. To attempt to create a game engine you require a depth of knowledge in hardware, graphics 3D theory (get comfortable with transform matrices and rotors and all that math goodies behind it), graphics APIs like directx and openGL, compiler theory as well as strong fundamentals in assembly, C and C and a lot of experience.

CodePudding user response:

SO, here's a very streamlined explanation of how the Unity Inspector works:

  1. Find all classes in a project (assembly and any other assemblies that it references) that inherit from MonoBehavior.
  2. Find all instances of those classes, based on the Scene.
  3. Use RTTI to enumerate a list of public properties for those instances.
  4. Provide an editor control - textbox, checkbox, or whatever - for those fields based on the type of the enumerated property.
  5. When the content of those controls change, update the values of the associated property for the associated instance.
  6. Serialize the whole thing and dump it to disk.

It's not hard, per se, to do that - but it is very involved, even with a language like C# that supports RTTI out of the box. Doing that with C is going to take some magic. The Unreal implementation is a nightmare (IMHO).

If that description is a Miata, then Unity's implementation is a Formula 1 car. I can't go into details, but there's a lot of magic behind the scenes that makes it work as well as it does.

You're effectively trying to write a basic debugger. In C#, Delphi (long time ago) and languages that provide RTTI, it's doable. In C , you're going to have to jump through some flaming hoops. Pick another language for your scripting.

  •  Tags:  
  • c
  • Related