Exemple #1
0
        private void Run()
        {
            Debug.Log("Run");
            live2DModel.textureFiles = new Texture2D[texture_filepath.Length];
            for (int i = 0; i < texture_filepath.Length; i++)
            {
                if (string.IsNullOrEmpty(texture_filepath [i]))
                {
                    continue;
                }

                Texture2D tex = new Texture2D(2, 2);
                tex.LoadImage(File.ReadAllBytes(texture_filepath [i]));
                live2DModel.textureFiles [i] = tex;
            }
            if (!string.IsNullOrEmpty(shizuku_moc_filepath))
            {
                live2DModel.setMocFileFromBytes(File.ReadAllBytes(shizuku_moc_filepath));
            }
            if (!string.IsNullOrEmpty(shizuku_physics_filepath))
            {
                live2DModel.setPhysicsFileFromBytes(File.ReadAllBytes(shizuku_physics_filepath));
            }
            if (!string.IsNullOrEmpty(shizuku_pose_filepath))
            {
                live2DModel.setPoseFileFromBytes(File.ReadAllBytes(shizuku_pose_filepath));
            }


            faceLandmarkDetector = new FaceLandmarkDetector(shape_predictor_68_face_landmarks_dat_filepath);
            frontalFaceParam     = new FrontalFaceParam();

            webCamTextureToMatHelper.Init();
        }
        private void Run()
        {
            Debug.Log("Run");
            if (webCamTextureToMatHelper == null)
            {
                //webCamTextureToMatHelper = gameObject.GetComponent<WebCamTextureToMatHelper>();
                //webCamTextureToMatHelper = GetComponent<WebCamTextureToMatHelper>();
                //webCamTextureToMatHelper = new WebCamTextureToMatHelper();
                webCamTextureToMatHelper = gameObject.AddComponent <WebCamTextureToMatHelper>() as WebCamTextureToMatHelper;
            }
            live2DModel.textureFiles = new Texture2D[texture_filepath.Length];
            for (int i = 0; i < texture_filepath.Length; i++)
            {
                if (string.IsNullOrEmpty(texture_filepath[i]))
                {
                    continue;
                }

                Texture2D tex = new Texture2D(2, 2);
                tex.LoadImage(File.ReadAllBytes(texture_filepath[i]));
                live2DModel.textureFiles[i] = tex;
            }
            if (!string.IsNullOrEmpty(shizuku_moc_filepath))
            {
                live2DModel.setMocFileFromBytes(File.ReadAllBytes(shizuku_moc_filepath));
            }
            if (!string.IsNullOrEmpty(shizuku_physics_filepath))
            {
                live2DModel.setPhysicsFileFromBytes(File.ReadAllBytes(shizuku_physics_filepath));
            }
            if (!string.IsNullOrEmpty(shizuku_pose_filepath))
            {
                live2DModel.setPoseFileFromBytes(File.ReadAllBytes(shizuku_pose_filepath));
            }

            Debug.Log(shape_predictor_68_face_landmarks_dat_filepath);
            faceLandmarkDetector = new FaceLandmarkDetector(shape_predictor_68_face_landmarks_dat_filepath);
            Debug.Log(faceLandmarkDetector);


            frontalFaceParam = new FrontalFaceParam();

            webCamTextureToMatHelper.Initialize(null, webCamTextureToMatHelper.requestWidth2(), webCamTextureToMatHelper.requestHeight2(), !webCamTextureToMatHelper.requestIsFrontFacing2());
            webCamTextureToMatHelper.onInitialized.AddListener(OnWebCamTextureToMatHelperInited);
            webCamTextureToMatHelper.Initialize(null, webCamTextureToMatHelper.requestWidth2(), webCamTextureToMatHelper.requestHeight2(), !webCamTextureToMatHelper.requestIsFrontFacing2());
            isInitedWCT2M = false;
            webCamTextureToMatHelper.onInitialized.AddListener(OnWebCamTextureToMatHelperInited);

            //webCamTextureToMatHelper.Initialize ();
        }