Skip to content

VGO runtime loading

IzayoiJiichan edited this page Aug 3, 2023 · 14 revisions

1. Load scene

Load LoadScene when using the UniVGO sample project.

image1

2. File settings

Select the VgoLoader game object in Hierarchy,
In Inspector, enter the full path of the VGO file you want to load at runtime in Local File Path.

image1

image1

3. Run game

Press the play button to run the game.

Confirm that the VGO file is loaded.

If an error has occurred, the Console will display the details of the error.

Script

If you write your own script, write as follows.

    using System;
    using UnityEngine;
    using UniVgo2;

    public class RuntimeLoadBehaviour : MonoBehaviour
    {
        private readonly VgoImporter _VgoImporter = new();

        [SerializeField]
        private string _FilePath = string.Empty;

        private IDisposable? _VgoModelAssetDisposer;

        private void Start()
        {
            VgoModelAsset vgoModelAsset = _VgoImporter.Load(_FilePath);

            vgoModelAsset.ReflectSkybox(Camera.main);

            _VgoModelAssetDisposer = vgoModelAsset;
        }

        private void OnDestroy()
        {
            _VgoModelAssetDisposer?.Dispose();
        }
    }