Skip to content

Commit

Permalink
解决有些学生摸头不会跟随鼠标移动的问题(其实是摸头动画影响到了骨骼移动
Browse files Browse the repository at this point in the history
  • Loading branch information
Tualin14 committed Dec 17, 2022
1 parent 51b93e8 commit 76c10e8
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 118 deletions.
44 changes: 30 additions & 14 deletions Assets/C_Script/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class Control : MonoBehaviour
{
public GameObject spineBase,bgBase, debug, rBase;
public GameObject spineBase, bgBase, debug, rBase;
public Button lookBtn, patBtn, talkBtn;
public AudioSource voice, bgm, se;
public Text debugText;
Expand All @@ -38,6 +38,7 @@ public class Control : MonoBehaviour

//Pat
bool isPatting = false;
bool isFirstPat = false;
bool patEnding = false;
float patSpeed = 2;
float patRange = 0.5f;
Expand Down Expand Up @@ -96,6 +97,9 @@ IEnumerator Start()
se.gameObject.SetActive(false);
}

patRange = setting.pat.range;
lookRange = setting.lookRange;

string studentName = setting.student;
string voicePath = Path.Combine(dataFolderPath, "Voice");

Expand Down Expand Up @@ -357,6 +361,7 @@ void Update()
downPoint.y = pat.y;

downPoint = rBase.transform.TransformPoint(downPoint);

patBone.SetPositionSkeletonSpace(downPoint);
}
else if (patEnding)
Expand Down Expand Up @@ -419,7 +424,7 @@ void Update()
}
}



public void SetTalking()
{
Expand All @@ -432,8 +437,10 @@ public void SetTalking()
}

secondVoiceIndex = 1;
sprAnim.AnimationState.SetAnimation(3, "Talk_0" + voiceIndex + "_A", false);
sprAnim.AnimationState.SetAnimation(4, "Talk_0" + voiceIndex + "_M", false);
sprAnim.AnimationState.AddEmptyAnimation(3, 0.2f, 0);
sprAnim.AnimationState.AddEmptyAnimation(4, 0.2f, 0);
sprAnim.AnimationState.AddAnimation(3, "Talk_0" + voiceIndex + "_A", false, 0);
sprAnim.AnimationState.AddAnimation(4, "Talk_0" + voiceIndex + "_M", false, 0);
sprAnim.AnimationState.AddEmptyAnimation(3, 0.2f, 0);
sprAnim.AnimationState.AddEmptyAnimation(4, 0.2f, 0);
voiceIndex++;
Expand All @@ -448,13 +455,21 @@ public void SetPatting(bool b)
isPatting = b;
if (b)
{
if (patA != null)
{
sprAnim.AnimationState.SetAnimation(1, patA, false);
}
if (patM != null)
if (!isFirstPat)
{
sprAnim.AnimationState.SetAnimation(2, patM, false);
isFirstPat = true;
if (patA != null)
{
sprAnim.AnimationState.SetAnimation(1, patA, false);
}
if (patM != null)
{
sprAnim.AnimationState.SetAnimation(2, patM, false);
if (setting.pat.somethingWrong)
{
sprAnim.AnimationState.AddEmptyAnimation(2, 0, 0);
}
}
}
}
else
Expand All @@ -467,10 +482,11 @@ public void SetPatting(bool b)
{
sprAnim.AnimationState.AddAnimation(2, patEndM, false, 0);
}
sprAnim.AnimationState.AddEmptyAnimation(1, 0.5f, 0);
sprAnim.AnimationState.AddEmptyAnimation(2, 0.5f, 0);
sprAnim.AnimationState.AddEmptyAnimation(1, 0.2f, 0);
sprAnim.AnimationState.AddEmptyAnimation(2, 0.2f, 0);

patEnding = true;
isFirstPat = false;
}
}
}
Expand Down Expand Up @@ -563,8 +579,8 @@ public void SetLooking(bool b)
{
sprAnim.AnimationState.AddAnimation(2, lookEndM, false, 0);
}
sprAnim.AnimationState.AddEmptyAnimation(1, 0.5f, 0);
sprAnim.AnimationState.AddEmptyAnimation(2, 0.5f, 0);
sprAnim.AnimationState.AddEmptyAnimation(1, 0.2f, 0);
sprAnim.AnimationState.AddEmptyAnimation(2, 0.2f, 0);

lookEnding = true;
}
Expand Down
9 changes: 9 additions & 0 deletions Assets/C_Script/Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class Setting
public bool debug;
public bool rotation;
public float scale;
public float lookRange;
public Pat pat;
public Bgm bgm;
public Se se;
public Talk talk;
Expand All @@ -23,6 +25,13 @@ public class Bgm
public float volume;
}

[Serializable]
public class Pat
{
public float range;
public bool somethingWrong;
}

[Serializable]
public class Se
{
Expand Down
56 changes: 51 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
- debug 调试,查看触发位置
- rotation 摆正人物,可以给类似心奈的学生使用
- scale 缩放
- lookRange 注释范围,形状为边与两眼平行的正方形
- pat
- range 摸头范围,形状为与两眼平行的线
- somethingWrong 如果摸头没有跟随鼠标移动,则设置此为true
- imageList 图片列表,有多少写多少
- bgm
- enable 若想静音 bgm 可直接关闭,节约一点内存
Expand All @@ -29,9 +33,9 @@
- name 音效文件名
- volume 音量 0.0~1.0
- talk
- volume 音量 0.0~1.0
- onlyTalk 有些学生声音事件没有具体指明,都为 Talk 事件时开启。false 没声音改成 true 就行
- maxIndex 语音动画数
- volume 音量 0.0~1.0
- onlyTalk 有些学生声音事件没有具体指明,都为 Talk 事件时开启。false 没声音改成 true 就行
- maxIndex 语音动画数
- bone
- eyeL 左眼根骨骼名
- eyeR 右眼根骨骼名
Expand All @@ -55,6 +59,8 @@ public class Setting
public bool debug;
public bool rotation;
public float scale;
public float lookRange;
public Pat pat;
public Bgm bgm;
public Se se;
public Talk talk;
Expand All @@ -70,6 +76,13 @@ public class Setting
public float volume;
}

[Serializable]
public class Pat
{
public float range;
public bool somethingWrong;
}

[Serializable]
public class Se
{
Expand Down Expand Up @@ -111,9 +124,7 @@ public class Setting
public bool more;
public string name;
}

}

</pre>
</details>

Expand Down Expand Up @@ -238,6 +249,41 @@ public class Setting
</pre>
</details>

<details>
<summary>日步美(解决摸头不随鼠标移动</summary>
<pre>
{
"student": "Hihumi_home",
"debug": true,
"rotation": false,
"scale": 1,
"lookRange": 0.5,
"pat": {
"range": 0.3,
"somethingWrong": true
},
"imageList": [
"Hihumi_home",
"Hihumi_home2"
],
"bgm": {
"enable": true,
"volume": 0.3
},
"talk": {
"volume": 1,
"onlyTalk": false,
"maxIndex": 6
},
"bone": {
"eyeL": "L_Eye_01",
"eyeR": "R_Eye_01",
"halo": "Halo_01",
"neck": "Neck"
}
}</pre>
</details>

# Credits

- [spine-unity](http://zh.esotericsoftware.com/spine-unity)
Expand Down
99 changes: 0 additions & 99 deletions README_old.md

This file was deleted.

0 comments on commit 76c10e8

Please sign in to comment.