Solved Getting lastDecaytime?

Discussion in 'Rust Development' started by miRror, Oct 28, 2015.

  1. Wulf

    Wulf Community Admin

    Use reflection to get it.
     
  2. Thanks!
     
  3. @miRror Did you do this ?
    I tried trying to use Reflection for my first time .. and it didnt go well(I read some tutorials too).... could you give me an example of how it would go ?
     
  4. Wulf

    Wulf Community Admin

    There are a lot of examples floating around. Our extension for The Forest is a prime example for this. Just search for BindingFlags.
     
  5. Sorry, i mixed thread.
    Code:
    private FieldInfo lastTouchedTime = typeof(Decay).GetField("lastTouchedTime", (BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.GetField));
    Decay - class, lastTouchedTime - variable

    Use in my example:
    Code:
    Decay decay = block.GetComponent<Decay>();
    lastTouchedTime.GetValue(decay); // getting value variable lastTouchedTime in class Decay
    And see: http://www.dotnetperls.com/reflection