Editor PrefabUtility refusal to modify a component owned by Udon

Hello, I’ve come to contact you here, since I haven’t found any answer to the problem I’ve encountered.

In fact, in my project, I am using the unity editor.

I’m going to make an auto setup, that means that I want to create a system that implements all my system that I made by myself.

However, when I want to modify a variable in a component with my UdonSharp scripts I always get this error.

System.NullReferenceException: Object reference not set to an instance of an object

However I can add new components and even modify the basic Unity components, but as soon as I want to modify a script made in UdonSharp it is a problem.

I can also retrieve my script, but I can’t modify it.

GameObject KnifeTemp = PrefabUtility.InstantiatePrefab(KnifePrefab) as GameObject;
KnifeTemp.GetComponent<KnifeClassic>().NameOfSpawn = i;

For example I want to add an AudioSource component, it works, here is an example.

GameObject KnifeTemp = PrefabUtility.InstantiatePrefab(KnifePrefab) as GameObject;
KnifeTemp.AddComponent<AudioSource>();

It’s Work !
I want to modify the already existing component named Rigidbody and I set the gravity (useGravity) to “false” it’s work too.

Src :

1 Like

I found my solution : Editor Scripting · MerlinVR/UdonSharp Wiki · GitHub