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

Commit

Permalink
Add inspector for Interaction text and proximity
Browse files Browse the repository at this point in the history
- Add inspector for interaction text and proximity on UdonSharpBehaviours that have an Interact event
  • Loading branch information
MerlinVR committed Apr 5, 2020
1 parent 4092443 commit 36a29aa
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Assets/UdonSharp/Editor/UdonSharpProgramAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class UdonSharpProgramAsset : UdonAssemblyProgramAsset
[HideInInspector]
public ClassDebugInfo debugInfo = null;

[SerializeField]
private bool hasInteractEvent = false;

[SerializeField, HideInInspector]
private SerializationData serializationData;

Expand Down Expand Up @@ -96,6 +99,16 @@ protected override void DrawProgramSourceGUI(UdonBehaviour udonBehaviour, ref bo
GUI.enabled = GUI.enabled || shouldUseRuntimeValue;
shouldUseRuntimeValue &= GUI.enabled;

if (currentBehaviour != null && hasInteractEvent)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Interact", EditorStyles.boldLabel);
currentBehaviour.interactText = EditorGUILayout.TextField("Interaction Text", currentBehaviour.interactText);
currentBehaviour.proximity = EditorGUILayout.Slider("Proximity", currentBehaviour.proximity, 0f, 100f);
}

EditorGUILayout.Space();

DrawPublicVariables(udonBehaviour, ref dirty);

if (currentBehaviour != null && !shouldUseRuntimeValue && program != null)
Expand Down Expand Up @@ -203,6 +216,17 @@ public void AssembleCsProgram(uint heapSize)
{
program = assemblerInterface.Assemble(udonAssembly);
assemblyError.SetValue(this, null);

hasInteractEvent = false;

foreach (string entryPoint in program.EntryPoints.GetExportedSymbols())
{
if (entryPoint == "_interact")
{
hasInteractEvent = true;
break;
}
}
}
catch (Exception e)
{
Expand Down

0 comments on commit 36a29aa

Please sign in to comment.