Example #1
0
        protected void Start()
        {
            if (string.IsNullOrEmpty(ModelPath) || string.IsNullOrEmpty(MotionPath) || string.IsNullOrEmpty(CameraPath))
            {
                Debug.LogError("please fill your model, motion and camera file path");
            }
            var mmdObj        = MmdGameObject.CreateGameObject("MmdGameObject");
            var mmdGameObject = mmdObj.GetComponent <MmdGameObject>();

            mmdGameObject.LoadModel(ModelPath);
            mmdGameObject.LoadMotion(MotionPath);

            //You can set model render options
            mmdGameObject.UpdateConfig(new MmdUnityConfig
            {
                EnableDrawSelfShadow = MmdConfigSwitch.ForceFalse,
                EnableCastShadow     = MmdConfigSwitch.ForceFalse
            });

            mmdGameObject.Playing = true;

            var mmdCamera = MmdCameraObject.CreateGameObject("MmdCameraObject").GetComponent <MmdCameraObject>();

            mmdCamera.LoadCameraMotion(CameraPath);
            mmdCamera.Playing = true;
        }
 private void InitScene()
 {
     CreatePyramidCameras();
     currentControlledMmd = MmdGameObject.CreateGameObject();
     _audioSource         = gameObject.AddComponent(typeof(AudioSource)) as AudioSource;
     InitTouchScreenEvent();
 }
Example #3
0
        public bool AddModel(string path)
        {
            var added         = MmdGameObject.CreateGameObject();
            var mmdGameObject = added.GetComponent <MmdGameObject>();

            mmdGameObject.PhysicsFps = PlayerPrefs.GetInt(UserConfigs.PhysicsFps, 120);
            mmdGameObject.OnMmdEvent = mmdEvent =>
            {
                if (mmdEvent == MmdGameObject.MmdEvent.SlowPoseCalculation && DotMark != null &&
                    PlayerPrefs.GetInt(UserConfigs.ShowSlowPhysics) != 0)
                {
                    DotMark.Show();
                }
            };
            var config = mmdGameObject.GetConfig();

            config.EnableDrawSelfShadow = PlayerPrefs.GetInt(UserConfigs.DrawShadow, 1) == 0
                ? MmdConfigSwitch.ForceFalse
                : MmdConfigSwitch.AsConfig;
            config.EnableEdge = MmdConfigSwitch.ForceFalse;
            mmdGameObject.UpdateConfig(config);
            if (!added.GetComponent <MmdGameObject>().LoadModel(path))
            {
                Destroy(added);
                return(false);
            }
            _mmdObjects.Add(added);
            ResetAll();
            SetSelectedModelIndex(_mmdObjects.Count - 1);
            return(true);
        }
Example #4
0
        private void StartPlay()
        {
            var mmdObj        = MmdGameObject.CreateGameObject("MmdGameObject");
            var mmdGameObject = mmdObj.GetComponent <MmdGameObject>();

            mmdGameObject.LoadModel(ModelPath);
            mmdGameObject.LoadBonePoseFile(BonePoseFileOutputPath);
            mmdGameObject.Playing = true;
        }
        //OYM:好吧...看来是非要把这个插件肝穿不可
        protected void Start()
        {
            if (isLoadModel)
            {
                if (string.IsNullOrEmpty(ModelPath))
                {
                    Debug.LogError("please fill your model file path and camera ");
                }
                var mmdObj        = MmdGameObject.CreateGameObject("MmdGameObject"); //OYM:创造一个mmd播放,这里值得我参考一下
                var mmdGameObject = mmdObj.GetComponent <MmdGameObject>();           //OYM:获取上面的组件
                mmdGameObject.LoadModel(ModelPath);                                  //OYM:加载模型

                if (isLoadMotion)
                {
                    if (string.IsNullOrEmpty(MotionPath))
                    {
                        Debug.LogError("please fill your motion file path ");
                    }
                    else
                    {
                        mmdGameObject.LoadMotion(MotionPath);//OYM:加载动作
                        //You can set model render options
                        //OYM:设置模型渲染模式(这里先不去动他)
                        mmdGameObject.UpdateConfig(new MmdUnityConfig
                        {
                            EnableDrawSelfShadow = MmdConfigSwitch.ForceFalse,
                            EnableCastShadow     = MmdConfigSwitch.ForceFalse
                        });

                        mmdGameObject.Playing = true;//OYM:设置播放
                    }
                }

                if (isLoadPath)
                {
                    if (string.IsNullOrEmpty(CameraPath))
                    {
                        Debug.LogError("please fill your motion file path ");
                    }
                    else
                    {
                        //OYM:下面三个都是相机导入和播放的,这里也别去碰他,现在还不需要用到
                        var mmdCamera = MmdCameraObject.CreateGameObject("MmdCameraObject").GetComponent <MmdCameraObject>();
                        mmdCamera.LoadCameraMotion(CameraPath);
                        mmdCamera.Playing = true;
                    }
                }
            }
        }