Ejemplo n.º 1
0
    /// <summary>
    /// load model from list
    /// </summary>
    /// <param name="filepath">target file path</param>
    public async void LoadModelFromDB(string filepath)
    {
        if (!downloader.GetDownloadStatus())
        {
            DownloadedFile data = null;
            await Task.Run(() =>
            {
                data = downloader.DownloadFileFromStorage(filepath, auth.User).Result;
            });

            var taggedObject = GameObject.FindGameObjectsWithTag("Player");
            foreach (GameObject current in taggedObject)
            {
                Destroy(current);
            }
            //loading model
            if (data.Type == "application/vrm")
            {
                Debug.Log("Stasrt loading VRM");
                await vrmloader.LoadVRM(data.File);
            }
        }
        else
        {
            Debug.LogError("Download in progress");
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// load model from list
    /// </summary>
    /// <param name="filepath">target file path</param>
    public async void LoadModelFromDB(string filepath)
    {
        if (!downloader.GetDownloadStatus())
        {
            DownloadedFile data = null;
            await Task.Run(() =>
            {
                data = downloader.DownloadFileFromStorage(filepath, auth.User).Result;
            });

            var taggedObject = GameObject.FindGameObjectsWithTag("Player");
            foreach (GameObject target in taggedObject)
            {
                Destroy(target);
            }
            if (GameObject.Find("Live2DCubism3CVVTuberExample"))
            {
                Destroy(GameObject.Find("Live2DCubism3CVVTuberExample"));
            }
            if (GameObject.Find("VRMCVVTuberExample"))
            {
                Destroy(GameObject.Find("VRMCVVTuberExample"));
            }
            //loading model
            if (data.Type == "application/json")
            {
                Debug.Log("Stasrt loading Live2D");
                live2dloader.LoadModelFromCompressor(data.File);
                //add Vtuber system to this model
                await Task.Delay(500);

                CubismModel target = GameObject.FindGameObjectWithTag("Player").GetComponent <CubismModel>();
                target.gameObject.AddComponent <ObjectMover>();
                target.gameObject.AddComponent <LookAround>();

                /*
                 * target.gameObject.GetComponent<Animator>().runtimeAnimatorController = animation;
                 * target.transform.Translate(0, 1.5f, 0);
                 * var loader = Instantiate(live2DcvLoader);
                 * loader.name = live2DcvLoader.name;
                 *
                 * HRC = GameObject.Find("Live2DCubism3CVVTuberExample/Live2DCubism3HeadRotationController").GetComponent<Live2DCubism3HeadRotationController>();
                 * FAC = GameObject.Find("Live2DCubism3CVVTuberExample/Live2DCubism3FaceAnimationController").GetComponent<Live2DCubism3FaceAnimationController>();
                 * CVVCM = GameObject.Find("Live2DCubism3CVVTuberExample/Live2DCubism3ControllManager").GetComponent<CVVTuberControllManager>();
                 * GameObject.Find("Live2DCubism3CVVTuberExample/DlibFaceLandmarkGetter").GetComponent<DlibFaceLandmarkGetter>().screen = GameObject.Find("Canvas/RawImage").GetComponent<RawImage>();
                 * HRC.target = target;
                 * FAC.live2DCubism3Model = target;
                 * GameObject.Find("Live2DCubism3CVVTuberExample/Live2DCubism3KeyInputExpressionController").GetComponent<Live2DCubism3KeyInputExpressionController>().target = target.gameObject.GetComponent<Animator>();
                 * GameObject.Find("Live2DCubism3CVVTuberExample/Live2DCubism3ControllManager").GetComponent<CVVTuberControllManager>().enabled = true;
                 */
            }
            else if (data.Type == "application/vrm")
            {
                Debug.Log("Stasrt loading VRM");
                await vrmloader.LoadVRM(data.File);

                /*
                 * var Instance = Instantiate(VRMcvLoader);
                 * Instance.name = VRMcvLoader.name;
                 * var currentGameObject = GameObject.Find("VRMCVVTuberExample/VRMControllManager");
                 * var loader = currentGameObject.GetComponent<CVVTuber.VRM.VRMLoader>();
                 * loader.meta = GameObject.FindGameObjectWithTag("Player").GetComponent<VRM.VRMMeta>();
                 * GameObject.Find("VRMCVVTuberExample/DlibFaceLandmarkGetter").GetComponent<DlibFaceLandmarkGetter>().screen = GameObject.Find("Canvas/RawImage").GetComponent<RawImage>();
                 * currentGameObject.GetComponent<CVVTuber.VRM.VRMCVVTuberControllManager>().enabled = true;
                 */
            }
        }
        else
        {
            Debug.LogError("Download in progress");
        }
    }