Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When added field is removed in play-session it'll start throwing exceptions and will stop additional-values from rendering in editor #8

Open
handzlikchris opened this issue Apr 4, 2023 · 8 comments

Comments

@handzlikchris
Copy link
Owner

No description provided.

@RunninglVlan
Copy link
Contributor

I can't reproduce this. Is this still relevant?
My test case:
Original:

using UnityEngine;
using UnityEngine.InputSystem;

public class Test : MonoBehaviour {
    void Update() {
        if (Keyboard.current.kKey.wasPressedThisFrame) {
            Debug.Log("Pressed {key}");
        }
    }
}

Added field:

using UnityEngine;
using UnityEngine.InputSystem;

public class Test : MonoBehaviour {
    [SerializeField] string key = "W";

    void Update() {
        if (Keyboard.current.kKey.wasPressedThisFrame) {
            Debug.Log($"Pressed {key}");
        }
    }
}

FSR generated:

using UnityEngine;
using UnityEngine.InputSystem;

public class Test__Patched_: MonoBehaviour {
    /* [SerializeField] string key = "W"; */ //Auto-excluded to prevent exceptions - see docs

    void Update() {
        if (Keyboard.current.kKey.wasPressedThisFrame) {
            Debug.Log($"Pressed {FastScriptReload.Scripts.Runtime.TemporaryNewFieldValues.ResolvePatchedObject<Test__Patched_>(this).key}");
        }
    }

private static global::System.Collections.Generic.Dictionary<string, global::System.Func<object>> __Patched_NewFieldNameToInitialValueFn = new global::System.Collections.Generic.Dictionary<string, global::System.Func<object>>
{
    ["key"] = () => "W",
};


private static global::System.Collections.Generic.Dictionary<string, global::System.Func<object>> __Patched_NewFieldsToGetTypeFnDictionaryFieldName = new global::System.Collections.Generic.Dictionary<string, global::System.Func<object>>
{
    ["key"] = () => typeof(string),
};

}

Removed field - reverted back to original, there were on issues. FSR generated:

using UnityEngine;
using UnityEngine.InputSystem;

public class Test__Patched_: MonoBehaviour {
    void Update() {
        if (Keyboard.current.kKey.wasPressedThisFrame) {
            Debug.Log("Pressed {key}");
        }
    }

private static global::System.Collections.Generic.Dictionary<string, global::System.Func<object>> __Patched_NewFieldNameToInitialValueFn = new global::System.Collections.Generic.Dictionary<string, global::System.Func<object>>
{
};


private static global::System.Collections.Generic.Dictionary<string, global::System.Func<object>> __Patched_NewFieldsToGetTypeFnDictionaryFieldName = new global::System.Collections.Generic.Dictionary<string, global::System.Func<object>>
{
};

}

@RunninglVlan
Copy link
Contributor

BTW, this serialize field isn't visible in Inspector. Do I need to do something else for it to appear?

new fields will only show in editor if they were already used at least once

Added field is used in the method

@handzlikchris
Copy link
Owner Author

Could be that issue was sorted but that ticket was not updated (can't remember looking into it though)

I'll have a peek tomorror / early next week.

Was that method called after FSR reload? This part is quite dynamic and it'll be able to render once code actually executed.

Ie adding it to method that did not yet run after reload won't cause it to show.

Is demo example working for you?

@handzlikchris
Copy link
Owner Author

@RunninglVlan Alright - I think this one will still be relevant but there's bigger issue where rendering of new fields is broken (#154). Without fixing it we won't be able to repro.

Btw - thanks for support on patreon, appreciate that!

@RunninglVlan
Copy link
Contributor

Is it possible to make issues depend on one another on GitHub?

@RunninglVlan
Copy link
Contributor

Is this issue only about SerializeFields? Because I tried with normal fields and couldn't reproduce it either way.

@handzlikchris
Copy link
Owner Author

Not sure, but when you add link it'll show in the other.

It's both, newly added fields won't render right now

@builder-main
Copy link
Collaborator

builder-main commented Mar 4, 2025

Is it possible to make issues depend on one another on GitHub?

You can copy the link in a comment, github will relate them. If by depend you mean a "subtask" then I think there are tools for that as well.

Also this menu exist on OP (maybe only to contributors though)
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

3 participants