예제 #1
0
    private void Start()
    {
        Avatar = null;

        _buttonVRM?.onClick.AddListener(async() =>
        {
            var bytes = await UniTask.Run(() => ReadBytes());

            if (bytes != null)
            {
                var context = new VRMImporterContext();

                await UniTask.Run(() => context.ParseGlb(bytes));
                var meta = context.ReadMeta(false);

                context.LoadAsync(() => OnLoaded(context));
            }
        });

        _buttonAssetBundle?.onClick.AddListener(async() =>
        {
            string path = await Task.Run(() => OpenFileName.ShowDialog("all", "."));

            //前のアバターの消去
            GameObject[] othreAvatars = GameObject.FindGameObjectsWithTag("Avatar");
            foreach (GameObject otherAvatar in othreAvatars)
            {
                Destroy(otherAvatar);
            }

            StartCoroutine(LoadBundleCoroutine(path));
        });
    }
예제 #2
0
        /// <summary>
        /// バイナリ列をVRMファイルとして読み込む
        /// </summary>
        /// <param name="characterBinary"></param>
        protected void LoadVRMFromBinary(byte[] characterBinary)
        {
            VRMImporterContext context = new VRMImporterContext();

            try
            {
                context.ParseGlb(characterBinary);
            }
            catch (Exception ex)
            {
                if (OnError != null)
                {
                    OnError(ex);
                }
                return;
            }
            context.LoadAsync(() =>
            {
                context.ShowMeshes();
                OnVrmModelLoaded(context.Root);
            },
                              onError: OnError);
        }