Skip to content

Commit

Permalink
Added target feature
Browse files Browse the repository at this point in the history
  • Loading branch information
from2001 committed Dec 26, 2023
1 parent d355314 commit c99d0e9
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class LoadVRM : Unit
[DoNotSerialize]
public ValueInput VrmURL;

[DoNotSerialize]
public ValueInput TargetGameobject;

[DoNotSerialize]
public ValueOutput result;

Expand All @@ -35,6 +38,7 @@ protected override void Definition()
outputTrigger = ControlOutput("outputTrigger");

VrmURL = ValueInput<string>("VRM URL", "");
TargetGameobject = ValueInput<GameObject>("Target Game Object", null);
result = ValueOutput<GameObject>("Game Object", (flow) => resultValue);

}
Expand All @@ -44,10 +48,20 @@ private IEnumerator Enter(Flow flow)
string url = flow.GetValue<string>(VrmURL);
Vrm10Instance vrmInstance = null;

// Load VRM
UniTask.Create(async () => { vrmInstance = await LoadVrm(url); }).Forget();
yield return new WaitUntil(() => vrmInstance);
resultValue = vrmInstance.gameObject;

// Set VRM location to Target Game Object
var Target = flow.GetValue<GameObject>(TargetGameobject);
if(Target != null){
vrmInstance.transform.SetParent(Target.transform);
vrmInstance.transform.localPosition = Vector3.zero;
vrmInstance.transform.localRotation = Quaternion.identity;
vrmInstance.transform.localScale = Vector3.one;
}

resultValue = vrmInstance.gameObject;
yield return outputTrigger;
}

Expand Down

0 comments on commit c99d0e9

Please sign in to comment.