Skip to content

Commit

Permalink
b6
Browse files Browse the repository at this point in the history
修复了 延迟触发表情 的文档错误
移除了 多轨播放动画(与1.20兼容性较差)
移除了 延迟面捕输入参数(好像没啥需要用到的地方)
  • Loading branch information
xiaoye97 committed Jul 22, 2022
1 parent ea230bf commit 8f9ff10
Show file tree
Hide file tree
Showing 19 changed files with 350 additions and 40 deletions.
14 changes: 11 additions & 3 deletions VTS_DelayExpression/DelayExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class DelayExpression : BaseUnityPlugin
public const string GUID = "me.xiaoye97.plugin.VTubeStudio.DelayExpression";
public const string PluginName = "DelayExpression[延迟触发表情]";
public const string PluginDescription = "按下快捷键后,根据配置的时间轴依次添加表情exp。[需要在配置文件中设置相关数据]";
public const string VERSION = "1.0.0";
public const string VERSION = "1.0.1";
public List<DelayExpressionConfig> configs = new List<DelayExpressionConfig>();

private string nowControlModel = "";
Expand Down Expand Up @@ -82,11 +82,18 @@ public void CheckInput()
// 如果当前模型不为空但是配置为空,则创建配置
if (configs == null || nowControlModel != XYModelManager.Instance.NowModelDef.Name)
{
nowControlModel = XYModelManager.Instance.NowModelDef.Name;
LoadConfig();
if (XYModelManager.Instance.NowModelDef != null)
{
nowControlModel = XYModelManager.Instance.NowModelDef.Name;
LoadConfig();
}
}
foreach (var config in configs)
{
if (config.PressingHotkey.Count == 0)
{
continue;
}
bool canPlay = true;
foreach (var hotkey in config.PressingHotkey)
{
Expand Down Expand Up @@ -139,6 +146,7 @@ public void LoadConfig()
}
else
{
XYLog.LogMessage($"DelayExpression:未找到配置文件 {path}");
//DelayExpressionConfig config = new DelayExpressionConfig();
//config.PressingHotkey = RawKey.Numpad4;
//config.GlobalHotkey = true;
Expand Down
88 changes: 75 additions & 13 deletions VTS_MutiMotionPlayer/Live2DModelAnimatorPatch.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using HarmonyLib;
using System.Collections.Generic;
using UnityEngine;

namespace VTS_MutiMotionPlayer
{
Expand All @@ -8,7 +9,8 @@ public static class Live2DModelAnimatorPatch
[HarmonyPrefix, HarmonyPatch(typeof(Live2DModelAnimator), "LateUpdate")]
public static bool Live2DModelAnimator_LateUpdate_Patch(Live2DModelAnimator __instance)
{
if (__instance.availableVTSModels.Count == 0)
__instance.modelCount = __instance.availableVTSModels.Count;
if (__instance.modelCount == 0)
{
return false;
}
Expand All @@ -27,45 +29,105 @@ public static bool Live2DModelAnimator_LateUpdate_Patch(Live2DModelAnimator __in
foreach (VTubeStudioModel vtubeStudioModel in __instance.availableVTSModels.Keys)
{
// 这里是主ParamStateController的刷新等操作
ModelDefinitionJSON modelJSON = vtubeStudioModel.ModelJSON;
bool flag = vtubeStudioModel != __instance.mainModel;
Live2DItemShift live2DItemShift = null;
float t = 1f;
if (flag)
{
bool flag2 = !modelJSON.ItemSettings.OnlyMoveWhenPinned || (modelJSON.ItemSettings.OnlyMoveWhenPinned && modelJSON.ItemSettings.ItemInfo != null && modelJSON.ItemSettings.ItemInfo.IsPinned);
modelJSON.ItemSettings.MovementFade = (modelJSON.ItemSettings.MovementFade + Time.deltaTime * 3.8f * (float)(flag2 ? 1 : -1)).Clamp01();
t = modelJSON.ItemSettings.MovementFade;
live2DItemShift = vtubeStudioModel.ItemShiftController;
}

vtubeStudioModel.ParamStateController.ExecuteStateStep();
bool flag = __instance.paramOverride.OverridesActive();
bool flag3 = __instance.paramOverride.OverridesActive();
foreach (ModelParamState modelParamState in vtubeStudioModel.ParamStateController.ParamStates)
{
if (!flag)
Live2DParamNames.Live2DParameterID paramID = Live2DParamNames.Live2DParameterID.NonDefault;
float num = 1f;
if (flag)
{
bool flag4;
paramID = __instance.step_GetItemMultiplierForParameter(modelParamState.Parameter, modelJSON, out num, out flag4);
if (flag4)
{
num = Mathf.Lerp(0f, num, t);
}
}
if (!flag3)
{
vtubeStudioModel.SetLive2DParam(modelParamState.Parameter, modelParamState.Value);
vtubeStudioModel.SetLive2DParam(modelParamState.Parameter, modelParamState.Value * num);
if (live2DItemShift != null)
{
live2DItemShift.SetParam(paramID, modelParamState.Value);
}
}
else if (flag)
else if (flag3)
{
if (!__instance.paramOverride.HasOverride(modelParamState.Parameter))
{
vtubeStudioModel.SetLive2DParam(modelParamState.Parameter, modelParamState.Parameter.DefaultValue);
vtubeStudioModel.SetLive2DParam(modelParamState.Parameter, modelParamState.Parameter.DefaultValue * num);
if (live2DItemShift != null)
{
live2DItemShift.SetParam(paramID, modelParamState.Parameter.DefaultValue);
}
}
else
{
vtubeStudioModel.SetLive2DParam(modelParamState.Parameter, __instance.paramOverride.GetOverride(modelParamState.Parameter));
float @override = __instance.paramOverride.GetOverride(modelParamState.Parameter);
vtubeStudioModel.SetLive2DParam(modelParamState.Parameter, @override);
if (live2DItemShift != null)
{
live2DItemShift.SetParam(paramID, @override);
}
}
}
}
// 紧接着刷新自己的ParamStateController
foreach (var psc in MutiMotionPlayer.NowModelMutiPSCs)
{
psc.ExecuteStateStep();
foreach (ModelParamState modelParamState in psc.ParamStates)
foreach (ModelParamState modelParamState in vtubeStudioModel.ParamStateController.ParamStates)
{
if (!flag)
Live2DParamNames.Live2DParameterID paramID = Live2DParamNames.Live2DParameterID.NonDefault;
float num = 1f;
if (flag)
{
vtubeStudioModel.SetLive2DParam(modelParamState.Parameter, modelParamState.Value);
bool flag4;
paramID = __instance.step_GetItemMultiplierForParameter(modelParamState.Parameter, modelJSON, out num, out flag4);
if (flag4)
{
num = Mathf.Lerp(0f, num, t);
}
}
if (!flag3)
{
vtubeStudioModel.SetLive2DParam(modelParamState.Parameter, modelParamState.Value * num);
if (live2DItemShift != null)
{
live2DItemShift.SetParam(paramID, modelParamState.Value);
}
}
else if (flag)
else if (flag3)
{
if (!__instance.paramOverride.HasOverride(modelParamState.Parameter))
{
vtubeStudioModel.SetLive2DParam(modelParamState.Parameter, modelParamState.Parameter.DefaultValue);
vtubeStudioModel.SetLive2DParam(modelParamState.Parameter, modelParamState.Parameter.DefaultValue * num);
if (live2DItemShift != null)
{
live2DItemShift.SetParam(paramID, modelParamState.Parameter.DefaultValue);
}
}
else
{
vtubeStudioModel.SetLive2DParam(modelParamState.Parameter, __instance.paramOverride.GetOverride(modelParamState.Parameter));
float @override = __instance.paramOverride.GetOverride(modelParamState.Parameter);
vtubeStudioModel.SetLive2DParam(modelParamState.Parameter, @override);
if (live2DItemShift != null)
{
live2DItemShift.SetParam(paramID, @override);
}
}
}
}
Expand Down
16 changes: 11 additions & 5 deletions VTS_MutiMotionPlayer/MiscPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ namespace VTS_MutiMotionPlayer
public static class MiscPatch
{
[HarmonyPrefix, HarmonyPatch(typeof(HotkeyManager), "SwitchToIdleAnimation")]
public static bool HotkeyManager_SwitchToIdleAnimation_Patch(HotkeyManager __instance, Live2DAnimation idleAnimation)
public static bool HotkeyManager_SwitchToIdleAnimation_Patch(HotkeyManager __instance, Live2DAnimation idleAnimation, VTubeStudioModel model)
{
// 检测动画是否是在多轨上,如果是的话由插件播放,如果不是则跳过
if (MutiMotionPlayer.NowControlMotionNames.Contains(idleAnimation.name))
if (model != __instance.mainModel)
{
var nowModel = XYModelManager.Instance.NowModel;
Live2DModelAnimatorPatch.Live2DModelAnimator_PlayAnimation_Patch(nowModel.ModelAnimator, nowModel, idleAnimation, Live2DAnimationType.IdleAnimation, false, -1f);
model.ModelAnimator.PlayAnimation(model, idleAnimation, Live2DAnimationType.IdleAnimation, false, -1f);
return false;
}
else
{
// 检测动画是否是在多轨上,如果是的话由插件播放,如果不是则跳过
if (MutiMotionPlayer.NowControlMotionNames.Contains(idleAnimation.name))
{
//var nowModel = XYModelManager.Instance.NowModel;
Live2DModelAnimatorPatch.Live2DModelAnimator_PlayAnimation_Patch(model.ModelAnimator, model, idleAnimation, Live2DAnimationType.IdleAnimation, false, -1f);
return false;
}
__instance.modelMetaDataItem.NormalIdleAnimationSwitchTriggeredByHotkey(idleAnimation);
return true;
}
}
Expand Down
6 changes: 3 additions & 3 deletions VTS_MutiMotionPlayer/MutiMotionPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

namespace VTS_MutiMotionPlayer
{
[BepInDependency("me.xiaoye97.plugin.VTubeStudio.VTS_XYPlugin", "2.0.0")]
[BepInPlugin(GUID, PluginName, VERSION)]
[ExScript(PluginName, PluginDescrition, "宵夜97", VERSION)]
//[BepInDependency("me.xiaoye97.plugin.VTubeStudio.VTS_XYPlugin", "2.0.0")]
//[BepInPlugin(GUID, PluginName, VERSION)]
//[ExScript(PluginName, PluginDescrition, "宵夜97", VERSION)]
public class MutiMotionPlayer : BaseUnityPlugin
{
public const string GUID = "me.xiaoye97.plugin.VTubeStudio.MutiMotionPlayer";
Expand Down
6 changes: 0 additions & 6 deletions VTS_XYPlugin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VTS_TimeParameter", "VTS_Ti
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VTS_DropDanMuSC", "VTS_DropDanMuSC\VTS_DropDanMuSC.csproj", "{F7A4854D-059D-49FB-BFD4-160F612EF364}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VTS_XYPluginWPF", "VTS_XYPluginWPF\VTS_XYPluginWPF.csproj", "{68BAD9BE-6622-49E9-A25B-1966302063B9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -77,10 +75,6 @@ Global
{F7A4854D-059D-49FB-BFD4-160F612EF364}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7A4854D-059D-49FB-BFD4-160F612EF364}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7A4854D-059D-49FB-BFD4-160F612EF364}.Release|Any CPU.Build.0 = Release|Any CPU
{68BAD9BE-6622-49E9-A25B-1966302063B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68BAD9BE-6622-49E9-A25B-1966302063B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68BAD9BE-6622-49E9-A25B-1966302063B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68BAD9BE-6622-49E9-A25B-1966302063B9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
19 changes: 19 additions & 0 deletions VTS_XYPlugin/XYRawKeyInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using UnityRawInput;
using VTS_XYPlugin_Common;
using UnityEngine;

namespace VTS_XYPlugin
{
Expand All @@ -12,6 +13,7 @@ public class XYRawKeyInput : MonoSingleton<XYRawKeyInput>
private static List<bool> LastFramePressed = new List<bool>();
private static List<bool> ThisFramePressed = new List<bool>();
public Action CheckInputAction;
public bool ShowDebugGUI;

public override void Init()
{
Expand Down Expand Up @@ -56,6 +58,23 @@ public void LateUpdate()
}
}

public void OnGUI()
{
if (ShowDebugGUI)
{
GUILayout.Space(20);
GUILayout.BeginVertical(GUI.skin.box);
for (int i = 0; i < KeyList.Count; i++)
{
if (ThisFramePressed[i])
{
GUILayout.Label(KeyList[i].ToString());
}
}
GUILayout.EndVertical();
}
}

public void RefreshXYHotkey()
{
RawKey switchMessageKey = (RawKey)XYPlugin.Instance.GlobalConfig.SwitchMessageSystemHotkey;
Expand Down
4 changes: 2 additions & 2 deletions VTS_XYPluginGUI/Assets/Scenes/XYPlugin.unity
Original file line number Diff line number Diff line change
Expand Up @@ -15179,7 +15179,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 195, y: 0}
m_SizeDelta: {x: 197, y: 0}
m_SizeDelta: {x: 183, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1046708304
MonoBehaviour:
Expand Down Expand Up @@ -24568,7 +24568,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 22edf581691d3ba478407fd40b1c3e41, type: 3}
m_Name:
m_EditorClassIdentifier:
Version: "Ver.2.0-\u516C\u5F00\u6D4B\u8BD5b5"
Version: "Ver.2.0-\u516C\u5F00\u6D4B\u8BD5b6"
--- !u!114 &1796244934
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"Parameter": "FaceAngleX",
"DelayTime": 1000.0
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# DelayInputParameter[延迟面捕输入参数]

## 这个扩展是做什么的?
将VTS的内置面捕输入参数延迟一定的时间(毫秒)再传输到输出参数。

此扩展的优先级低于使用API的面捕输入(如VBridger),如果使用此类插件,可以删除此扩展。

## 配置文件在代码中的结构定义

```C#
// 配置列表
public List<DelayInputParameterConfig> configs = new List<DelayInputParameterConfig>();

public class DelayInputParameterConfig
{
// 输入参数名
public string Parameter;
// 延迟时间(毫秒)
public float DelayTime;
}
```

## 如何编写DelayInputParameter的配置文件
首先复制一份给出的示例配置文件,将配置文件的名字改成 模型名.DelayInputParameter.json,然后根据需要修改配置文件即可。
示例文件的内容如下

`尚未团子.DelayInputParameter.json`
```json
[
{
"Parameter": "FaceAngleX",
"DelayTime": 1000.0
}
]
```

DelayTime的单位为毫秒
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# MutiMotionPlayer多轨动画播放

## 这个扩展是做什么的?
这个扩展可以让你通过`按住`快捷键来播放动画。

比如,你的模型上有一个风车,你想按住某个按键时播放高速风车的动画,松开按键时回到默认的低速动画,那么你可以使用这个扩展。
让VTS支持同时播放多个普通动画和多个idle动画。

## 配置文件在代码中的结构定义

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"DanMu": "大叫",
"AudioFile": "大叫.wav",
"Muti": true,
"Volume": 1.0,
"CD" : 5.0
},
{
"DanMu": "",
"AudioFile": "喵叫.wav",
"Muti": true,
"Volume": 1.0,
"CD" : 0.0
}
]
Loading

0 comments on commit 8f9ff10

Please sign in to comment.