CGerrits SF
4 年前
当前提交
f6c1ab34
共有 3 个文件被更改,包括 206 次插入 和 0 次删除
-
112Assets/BossRoom/Prefabs/Character/CharacterSet.prefab
-
83Assets/BossRoom/Scripts/Development/dgtest/CharacterSwap.cs
-
11Assets/BossRoom/Scripts/Development/dgtest/CharacterSwap.cs.meta
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
|
|||
namespace BossRoom.Client |
|||
{ |
|||
public class CharacterSwap : MonoBehaviour |
|||
{ |
|||
[System.SerializableAttribute] |
|||
public class CharacterModelSet |
|||
{ |
|||
public GameObject ears; |
|||
public GameObject head; |
|||
public GameObject mouth; |
|||
public GameObject hair; |
|||
public GameObject eyes; |
|||
public GameObject torso; |
|||
public GameObject gear_left_hand; |
|||
public GameObject gear_right_hand; |
|||
public GameObject hand_right; |
|||
public GameObject hand_left; |
|||
public GameObject shoulder_right; |
|||
public GameObject shoulder_left; |
|||
|
|||
|
|||
public void setFullActive(bool isActive) |
|||
{ |
|||
ears?.SetActive(isActive); |
|||
head?.SetActive(isActive); |
|||
mouth?.SetActive(isActive); |
|||
hair?.SetActive(isActive); |
|||
eyes?.SetActive(isActive); |
|||
torso?.SetActive(isActive); |
|||
gear_left_hand?.SetActive(isActive); |
|||
hand_right?.SetActive(isActive); |
|||
hand_left?.SetActive(isActive); |
|||
shoulder_right?.SetActive(isActive); |
|||
shoulder_left?.SetActive(isActive); |
|||
gear_left_hand?.SetActive(isActive); |
|||
gear_right_hand?.SetActive(isActive); |
|||
} |
|||
} |
|||
[SerializeField] |
|||
KeyCode hotswapKey; |
|||
|
|||
[SerializeField] |
|||
public int modelIndex = 0; |
|||
public CharacterModelSet[] characterModels; |
|||
|
|||
public void cycleModel() |
|||
{ |
|||
if (modelIndex == characterModels.Length) |
|||
{ |
|||
modelIndex = 0; |
|||
} |
|||
else |
|||
{ |
|||
modelIndex += 1; |
|||
} |
|||
this.swapToModel(modelIndex); |
|||
} |
|||
|
|||
|
|||
public void swapToModel(int idx) |
|||
{ |
|||
for (int x = 0; x < characterModels.Length; x++) |
|||
{ |
|||
characterModels[x].setFullActive(x == idx); |
|||
} |
|||
} |
|||
|
|||
// Update is called once per frame
|
|||
void Update() |
|||
{ |
|||
if (Input.GetKeyDown(hotswapKey)) |
|||
{ |
|||
cycleModel(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a3048059d1dc86848a814084448ace11 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue