예제 #1
0
 static void Postfix(OcPl __instance)
 {
     foreach (var mr in __instance.GetComponentsInChildren <MeshRenderer>())
     {
         mr.enabled = false;
     }
 }
예제 #2
0
        static void Postfix(OcPl __instance)
        {
            if (vrmModel == null)
            {
                //カスタムモデル名の取得(設定ファイルにないためLogの出力が不自然にならないよう調整)
                var ModelStr = Settings.ReadSettings("ModelName");
                var path     = Environment.CurrentDirectory + @"\Player2VRM\player.vrm";
                if (ModelStr != null)
                {
                    path = Environment.CurrentDirectory + @"\Player2VRM\" + ModelStr + ".vrm";
                }

                try
                {
                    vrmModel = ImportVRM(path);
                }
                catch
                {
                    if (ModelStr != null)
                    {
                        UnityEngine.Debug.LogWarning("VRMファイルの読み込みに失敗しました。settings.txt内のModelNameを確認してください。");
                    }
                    else
                    {
                        UnityEngine.Debug.LogWarning("VRMファイルの読み込みに失敗しました。Player2VRMフォルダにplayer.vrmを配置してください。");
                    }
                    return;
                }

                var receiveShadows = Settings.ReadBool("ReceiveShadows");
                if (!receiveShadows)
                {
                    foreach (var smr in vrmModel.GetComponentsInChildren <SkinnedMeshRenderer>())
                    {
                        smr.receiveShadows = false;
                    }
                }

                // プレイヤースケール調整
                {
                    var scaleStr = Settings.ReadSettings("PlayerScale");
                    var scale    = 1.0f;
                    if (scaleStr != null && float.TryParse(scaleStr, out scale))
                    {
                        __instance.transform.localScale *= scale;
                        vrmModel.transform.localScale   /= scale;
                    }
                }
            }

            foreach (var smr in __instance.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                foreach (var mat in smr.materials)
                {
                    mat.SetFloat("_EnableTextureTransparent", 1.0f);
                }
                smr.enabled = false;
                Transform trans = smr.transform;
                while (vrmModel != null && trans != null)
                {
                    if (trans.name.Contains(vrmModel.name))
                    {
                        smr.enabled = true;
                        break;
                    }
                    trans = trans.parent;
                }
            }

            if (__instance is OcPlMaster)
            {
                if (modelMaster == null)
                {
                    modelMaster = GameObject.Instantiate <GameObject>(vrmModel);
                }
                var instAnim   = __instance.GetComponentInChildren <Animator>();
                var masterAnim = modelMaster.GetComponentInChildren <Animator>();
                modelMaster.transform.SetParent(__instance.transform, false);
                masterAnim.runtimeAnimatorController = instAnim.runtimeAnimatorController;

                var fitter = __instance.GetComponent <AnimFitter>();
                if (fitter == null)
                {
                    fitter            = __instance.gameObject.AddComponent <AnimFitter>();
                    fitter.masterAnim = masterAnim;
                }
            }

            if (__instance is OcPlSlave)
            {
                if (modelSlave == null)
                {
                    modelSlave = GameObject.Instantiate <GameObject>(vrmModel);
                }
                var instAnim   = __instance.GetComponentInChildren <Animator>();
                var masterAnim = modelSlave.GetComponentInChildren <Animator>();
                modelSlave.transform.SetParent(__instance.transform, false);
                masterAnim.runtimeAnimatorController = instAnim.runtimeAnimatorController;

                var fitter = __instance.GetComponent <AnimFitter>();
                if (fitter == null)
                {
                    fitter            = __instance.gameObject.AddComponent <AnimFitter>();
                    fitter.masterAnim = masterAnim;
                }
            }
        }
예제 #3
0
        static void Postfix(OcPl __instance)
        {
            string playername = Settings.getPlayerName(__instance);

            if (playername == null)
            {
                GameObject obj = new GameObject("Delay_OcPlVRM");
                DelayVRM   dvm = obj.AddComponent <DelayVRM>();
                dvm.StartCheck(__instance);
                return;
            }

            if (!Settings.isUseVRM(__instance))
            {
                return;
            }


            if (Settings.ReadBool("DisableStool", false))
            {
                SROptions.Current.DisableStool = true;
            }

            GameObject _vrmModel = null;

            if (playername != null)
            {
                if (dic_vrmModel.ContainsKey(playername))
                {
                    _vrmModel = dic_vrmModel[playername];
                }
            }
            if (_vrmModel == null)
            {
                //カスタムモデル名の取得(設定ファイルにないためLogの出力が不自然にならないよう調整)
                var ModelStr = Settings.ReadSettings(playername, "ModelName");

                var path = Environment.CurrentDirectory + @"\Player2VRM\player.vrm";
                if (ModelStr != null)
                {
                    path = Environment.CurrentDirectory + @"\Player2VRM\" + ModelStr + ".vrm";
                }

                try
                {
                    _vrmModel = ImportVRM(path, playername);
                }
                catch
                {
                    string _settings_path = Settings.FindAvatarSettngs(playername);

                    if (ModelStr != null)
                    {
                        UnityEngine.Debug.LogWarning("VRMファイルの読み込みに失敗しました。" + _settings_path + "内のModelNameを確認してください。");
                    }
                    else
                    {
                        UnityEngine.Debug.LogWarning("VRMファイルの読み込みに失敗しました。Player2VRMフォルダにplayer.vrmを配置してください。");
                    }
                    return;
                }

                OcPlHeadPrefabSetting hps = __instance.gameObject.GetComponentInChildren <OcPlHeadPrefabSetting>();
                if (hps != null)
                {
                    foreach (var mr in hps.gameObject.GetComponentsInChildren <MeshRenderer>())
                    {
                        mr.enabled = false;
                    }
                }

                var receiveShadows = Settings.ReadBool(playername, "ReceiveShadows");
                if (!receiveShadows)
                {
                    foreach (var smr in _vrmModel.GetComponentsInChildren <SkinnedMeshRenderer>())
                    {
                        smr.receiveShadows = false;
                    }
                }

                // プレイヤースケール調整
                {
                    var scale = Settings.ReadFloat(playername, "PlayerScale", 1.0f);
                    __instance.transform.localScale *= scale;
                    _vrmModel.transform.localScale  /= scale;
                }
            }

            foreach (var smr in __instance.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                if (Settings.ReadBool(playername, "UseRealToonShader", false))
                {
                    foreach (var mat in smr.materials)
                    {
                        mat.SetFloat("_EnableTextureTransparent", 1.0f);
                    }
                }
                smr.enabled = false;
                Transform trans = smr.transform;
                while (_vrmModel != null && trans != null)
                {
                    if (trans.name.Contains(_vrmModel.name))
                    {
                        smr.enabled = true;
                        break;
                    }
                    trans = trans.parent;
                }
            }

            __instance.Animator.gameObject.GetOrAddComponent <CloneHumanoid>().Setup(_vrmModel, __instance.Animator, __instance is OcPlMaster);
            if (playername != null)
            {
                dic_vrmModel[playername] = _vrmModel;
            }
        }
예제 #4
0
        static void Postfix(OcPl __instance)
        {
            var slave = __instance as OcPlSlave;

            if (slave && !slave.FindNameInParentRecursive("UI"))
            {
                var selfId = OcNetMng.Inst.NetPlId_Master;
                if (SingletonMonoBehaviour <OcPlMng> .Inst.getPlSlave(selfId - 1) != slave)
                {
                    return;
                }
            }

            if (vrmModel == null)
            {
                //カスタムモデル名の取得(設定ファイルにないためLogの出力が不自然にならないよう調整)
                var ModelStr = Settings.ReadSettings("ModelName");
                var path     = Environment.CurrentDirectory + @"\Player2VRM\player.vrm";
                if (ModelStr != null)
                {
                    path = Environment.CurrentDirectory + @"\Player2VRM\" + ModelStr + ".vrm";
                }

                try
                {
                    vrmModel = ImportVRM(path);
                }
                catch
                {
                    if (ModelStr != null)
                    {
                        UnityEngine.Debug.LogWarning("VRMファイルの読み込みに失敗しました。settings.txt内のModelNameを確認してください。");
                    }
                    else
                    {
                        UnityEngine.Debug.LogWarning("VRMファイルの読み込みに失敗しました。Player2VRMフォルダにplayer.vrmを配置してください。");
                    }
                    return;
                }

                var receiveShadows = Settings.ReadBool("ReceiveShadows");
                if (!receiveShadows)
                {
                    foreach (var smr in vrmModel.GetComponentsInChildren <SkinnedMeshRenderer>())
                    {
                        smr.receiveShadows = false;
                    }
                }

                // プレイヤースケール調整
                {
                    var scale = Settings.ReadFloat("PlayerScale", 1.0f);
                    __instance.transform.localScale *= scale;
                    vrmModel.transform.localScale   /= scale;
                }
            }

            foreach (var smr in __instance.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                if (Settings.ReadBool("UseRealToonShader", false))
                {
                    foreach (var mat in smr.materials)
                    {
                        mat.SetFloat("_EnableTextureTransparent", 1.0f);
                    }
                }
                smr.enabled = false;
                Transform trans = smr.transform;
                while (vrmModel != null && trans != null)
                {
                    if (trans.name.Contains(vrmModel.name))
                    {
                        smr.enabled = true;
                        break;
                    }
                    trans = trans.parent;
                }
            }

            __instance.Animator.gameObject.GetOrAddComponent <CloneHumanoid>().Setup(vrmModel, __instance.Animator, __instance is OcPlMaster);
        }