Skip to content

Commit

Permalink
Merge pull request #54 from from2001/develop
Browse files Browse the repository at this point in the history
v0.1.3
  • Loading branch information
from2001 authored May 11, 2024
2 parents 55bf492 + 426a3f2 commit 3df94f1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.IO;
using STYLY.Http;
using STYLY.Http.Service;
using UnityGLTF;

namespace GltfastVisualScriptingNodes
{
Expand Down Expand Up @@ -62,7 +63,49 @@ private IEnumerator Enter(Flow flow)
yield return outputTrigger;
}


/// <summary>
/// Load glTF/glb with URL using UnityGLTF
/// </summary>
/// <param name="URL"></param>
/// <param name="target"></param>
/// <param name="normalizescale"></param>
/// <returns></returns>
private async UniTask<GameObject> LoadGltfWithURL(string URL, GameObject target = null, bool normalizescale = true)
{
// Create glTF GameObject
GameObject glTF = new("glTF");
var UnityGltfScript = glTF.AddComponent<GLTFComponent>();

// Set glTF loading parameters
UnityGltfScript.GLTFUri = URL;
UnityGltfScript.Multithreaded = true;
UnityGltfScript.UseStream = true;
UnityGltfScript.AppendStreamingAssets = false;
UnityGltfScript.PlayAnimationOnLoad = true;
UnityGltfScript.HideSceneObjDuringLoad = false;
UnityGltfScript.Factory = null;

// Load glTF/glb
await UnityGltfScript.Load();

// Adjust scale to 1 unit size
if (normalizescale) Utils.FitToUnitSize(glTF);

// Set glTF location to Target Game Object
if (target != null)
{
glTF.transform.SetParent(target.transform);
glTF.transform.localPosition = Vector3.zero;
glTF.transform.localRotation = Quaternion.identity;
glTF.transform.localScale = Vector3.one;
}

return glTF;
}

// This method is not used now.
private async UniTask<GameObject> LoadGltfWithURL_glTFast(string URL, GameObject target = null, bool normalizescale = true)
{
GameObject glTF = new("glTF"); // This is the parent object of the glTF instance. Always 1 unit size.
GameObject gltfInstance = new("glTFast");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.from2001.gltfast-visualscripting-nodes",
"version": "0.1.2",
"version": "0.1.3",
"displayName": "glTFast Visual Scripting Nodes",
"description": "Unity Visual Scripting node library for glTF",
"unity": "2021.3",
Expand Down

0 comments on commit 3df94f1

Please sign in to comment.