Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Re-enable UnityEngine.Object array get optimization
Browse files Browse the repository at this point in the history
- Now that c9c0ba5 fixes GetComponent<T>, we can re-enable this optimization
  • Loading branch information
MerlinVR committed Dec 4, 2020
1 parent c9c0ba5 commit 5f0dab4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Assets/UdonSharp/Editor/UdonSharpExpressionCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,9 @@ public SymbolDefinition ExecuteGet()
{
// udon-workaround: VRC scans UnityEngine.Object arrays in their respective methods, so those methods are useless since they get disproportionately expensive the larger the array is.
// Instead use the object[] indexer for these objects since it does not get scanned
// Breaks GetComponent(s)<T> since they depend on the heap strongbox type which gets changed to System.Object here instead of just getting the component assigned
//if (arraySymbolType.GetElementType() == typeof(UnityEngine.Object) || arraySymbolType.GetElementType().IsSubclassOf(typeof(UnityEngine.Object)))
// getIndexerUdonName = visitorContext.resolverContext.GetUdonMethodName(typeof(object[]).GetMethods(BindingFlags.Public | BindingFlags.Instance).First(e => e.Name == "Get"));
//else
if (arraySymbolType.GetElementType() == typeof(UnityEngine.Object) || arraySymbolType.GetElementType().IsSubclassOf(typeof(UnityEngine.Object)))
getIndexerUdonName = visitorContext.resolverContext.GetUdonMethodName(typeof(object[]).GetMethods(BindingFlags.Public | BindingFlags.Instance).First(e => e.Name == "Get"));
else
getIndexerUdonName = visitorContext.resolverContext.GetUdonMethodName(arraySymbolType.GetMethods(BindingFlags.Public | BindingFlags.Instance).First(e => e.Name == "Get"));

elementType = arraySymbol.userCsType.GetElementType();
Expand Down

0 comments on commit 5f0dab4

Please sign in to comment.