Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Load data and formula from a file?

Discussion in 'Scripting' started by SeriousBusinessFace, Jun 30, 2015.

  1. SeriousBusinessFace

    SeriousBusinessFace

    Joined:
    May 10, 2014
    Posts:
    127
    Let's say I have a starship component like this:

    Name: Nuclear Rocket
    Type: Propulsion
    // Other data
    # Resources: 1
    Resource Name 1: Nuclear Fuel // Name would be indexed against available resource names.
    Resource Use Type: Consumes // Also Stores, Produces...
    Resource Use Formula: (sqrt(ComponentSize) / Sqrt(RelativeTechLevel)) * // ...more math.

    Where the formulas and data would be used during runtime.

    Now, most obviously, a scripting language would be useful, here. This suggests several questions:

    1) Is it possible to load in C# .dll Assemblies in Unity C#? Because I already know how to do that, and if it's viable in Unity, I could write something myself if nothing else.
    2) Are there existing scripting language packages that could handle this? (probably)
    2b) If so, what would you recommend?
     
  2. eisenpony

    eisenpony

    Joined:
    May 8, 2015
    Posts:
    974
  3. SeriousBusinessFace

    SeriousBusinessFace

    Joined:
    May 10, 2014
    Posts:
    127
    1) I apologize; I was asking if AppDomain.Load(Assembly) works in Unity.
    2) See below.
    2b) I gather you do not agree with using scripting languages? Could you explain some of that, as they seem popular.

    Thanks.
     
  4. eisenpony

    eisenpony

    Joined:
    May 8, 2015
    Posts:
    974
    1) I'm not 100% sure about that - but I think the method in the documentation will achieve what you are trying to do won't it? It has the added benefit of being supported by the Unity staff.
    2) I'm not totally against it, I just think you should be careful when applying it - in particular consider the security risks. I think scripting languages can be a very powerful tool especially for quick iterations on domain specific content. However it is sometimes assumed to be the best approach without consideration of alternatives. Personally, I like the idea of converting to c# and compiling the code. That way you can get protection using existing and well known mechanisms such as obfuscation, code signing and memory testing. Of course nothing is bullet proof..