u/JasnahsFeet

▲ 2 r/unity

Okay so here's my code:

Stat stat = (Stat)FieldFinder.FindField(character, skill);
Debug.Log(skill);
Debug.Log(stat);
Debug.Log(score);
stat.SetValue(score);

and here is FindField

public static object FindField(object obj, string fieldName)
{
    Debug.Log("In object: " + obj);
    Debug.Log("Finding field: " + fieldName);
    Type type = obj.GetType();
    Debug.Log("In type: " + type);
    FieldInfo field = type.GetField(fieldName);
    Debug.Log("FieldInfo: " + field);
    if (field != null)
    {
        Debug.Log("Field found: " + field.Name);
        object value = field.GetValue(obj);
        Debug.Log("Value: " + value);
        return value;
    }
    else
    {
        Debug.LogWarning($"Field '{fieldName}' not found in object of type '{type.Name}'.");
        return null;
    }
}

Now what is strange about it is that this code seems to work differently, based on wether I have an object with Character in it in my inspector. If I don't it finds a field as it is supposed to (at least I think so), but then Debug.Log(stat) tells me it is null. If it is in my inspector, it works as it is supposed to. Is it a known glitch and do you know how to fix it?

reddit.com
u/JasnahsFeet — 10 days ago
▲ 1 r/UnityHelp+1 crossposts

So I have a very simple animation that's supposed to simply move an object up. I created it and noticed that (even though it works in edit mode), after entering play mode the animation changes to one where all transform are set the ones the object has normally, at the start of the game.

I made a small edit to test something on an animation that worked perfectly and suddenly it had the same bug. Almost like any change made after a specific moment completely breaks the animation

reddit.com
u/JasnahsFeet — 10 days ago