Skip to content

Commit 98e3bf1

Browse files
committed
Fix inspector field serialization
- Implement handling for OdinSerialize on UdonSharpProgramAsset since it's no longer working - Add error for attempting to compile a program asset without a source file specified
1 parent 4af84c8 commit 98e3bf1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Assets/UdonSharp/Editor/UdonSharpCompilationModule.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public CompilationModule(UdonSharpProgramAsset sourceAsset)
3737

3838
public int Compile(List<ClassDefinition> classDefinitions)
3939
{
40+
if (programAsset.sourceCsScript == null)
41+
throw new System.ArgumentException($"Asset '{AssetDatabase.GetAssetPath(programAsset)}' does not have a valid program source to compile from");
42+
4043
sourceCode = File.ReadAllText(AssetDatabase.GetAssetPath(programAsset.sourceCsScript));
4144

4245
SyntaxTree tree = CSharpSyntaxTree.ParseText(sourceCode);

Assets/UdonSharp/Editor/UdonSharpProgramAsset.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ void Start()
4141
[NonSerialized, OdinSerialize]
4242
public Dictionary<string, FieldDefinition> fieldDefinitions;
4343

44+
[SerializeField, HideInInspector]
45+
private SerializationData serializationData;
46+
4447
private static bool showProgramUasm = false;
4548

4649
protected override void DrawProgramSourceGUI(UdonBehaviour udonBehaviour, ref bool dirty)
@@ -514,6 +517,18 @@ protected override object DrawPublicVariableField(string symbol, object variable
514517

515518
return variableValue;
516519
}
520+
521+
protected override void OnBeforeSerialize()
522+
{
523+
UnitySerializationUtility.SerializeUnityObject(this, ref serializationData);
524+
base.OnBeforeSerialize();
525+
}
526+
527+
protected override void OnAfterDeserialize()
528+
{
529+
UnitySerializationUtility.DeserializeUnityObject(this, ref serializationData);
530+
base.OnAfterDeserialize();
531+
}
517532
}
518533

519534
[CustomEditor(typeof(UdonSharpProgramAsset))]

0 commit comments

Comments
 (0)