浏览代码

Continued work on swap script. Added missing gear slot and handling of unset objects

/main
CGerrits SF 4 年前
当前提交
f6c1ab34
共有 3 个文件被更改,包括 206 次插入0 次删除
  1. 112
      Assets/BossRoom/Prefabs/Character/CharacterSet.prefab
  2. 83
      Assets/BossRoom/Scripts/Development/dgtest/CharacterSwap.cs
  3. 11
      Assets/BossRoom/Scripts/Development/dgtest/CharacterSwap.cs.meta

112
Assets/BossRoom/Prefabs/Character/CharacterSet.prefab


- component: {fileID: 4199396739699390757}
- component: {fileID: 4532006264828386692}
- component: {fileID: 7943089997373843793}
- component: {fileID: 4654558647929214568}
m_Layer: 9
m_Name: CharacterSet
m_TagString: Untagged

MinZoomDistance: 3
MaxZoomDistance: 30
ZoomSpeed: 3
--- !u!114 &4654558647929214568
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3736552308919084700}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a3048059d1dc86848a814084448ace11, type: 3}
m_Name:
m_EditorClassIdentifier:
hotswapKey: 0
modelIndex: 0
characterModels:
- ears: {fileID: 0}
head: {fileID: 0}
mouth: {fileID: 0}
hair: {fileID: 0}
eyes: {fileID: 0}
torso: {fileID: 0}
gear_left_hand: {fileID: 0}
gear_right_hand: {fileID: 0}
hand_right: {fileID: 0}
hand_left: {fileID: 0}
shoulder_right: {fileID: 0}
shoulder_left: {fileID: 0}
- ears: {fileID: 0}
head: {fileID: 0}
mouth: {fileID: 0}
hair: {fileID: 0}
eyes: {fileID: 0}
torso: {fileID: 0}
gear_left_hand: {fileID: 0}
gear_right_hand: {fileID: 0}
hand_right: {fileID: 0}
hand_left: {fileID: 0}
shoulder_right: {fileID: 0}
shoulder_left: {fileID: 0}
- ears: {fileID: 0}
head: {fileID: 0}
mouth: {fileID: 0}
hair: {fileID: 0}
eyes: {fileID: 0}
torso: {fileID: 0}
gear_left_hand: {fileID: 0}
gear_right_hand: {fileID: 0}
hand_right: {fileID: 0}
hand_left: {fileID: 0}
shoulder_right: {fileID: 0}
shoulder_left: {fileID: 0}
- ears: {fileID: 4984529728629224612}
head: {fileID: 6384206623454602747}
mouth: {fileID: 3315647717772617126}
hair: {fileID: 3041631701937239552}
eyes: {fileID: 7705283312386798936}
torso: {fileID: 1497750831970152200}
gear_left_hand: {fileID: 4547385850525906434}
gear_right_hand: {fileID: 8332864890779340179}
hand_right: {fileID: 9187449357704579178}
hand_left: {fileID: 2875260262347090163}
shoulder_right: {fileID: 4547385852123078731}
shoulder_left: {fileID: 2503478013837759990}
- ears: {fileID: 0}
head: {fileID: 0}
mouth: {fileID: 0}
hair: {fileID: 0}
eyes: {fileID: 0}
torso: {fileID: 0}
gear_left_hand: {fileID: 0}
gear_right_hand: {fileID: 0}
hand_right: {fileID: 0}
hand_left: {fileID: 0}
shoulder_right: {fileID: 0}
shoulder_left: {fileID: 0}
- ears: {fileID: 0}
head: {fileID: 0}
mouth: {fileID: 0}
hair: {fileID: 0}
eyes: {fileID: 0}
torso: {fileID: 0}
gear_left_hand: {fileID: 0}
gear_right_hand: {fileID: 0}
hand_right: {fileID: 0}
hand_left: {fileID: 0}
shoulder_right: {fileID: 0}
shoulder_left: {fileID: 0}
- ears: {fileID: 0}
head: {fileID: 0}
mouth: {fileID: 0}
hair: {fileID: 0}
eyes: {fileID: 0}
torso: {fileID: 0}
gear_left_hand: {fileID: 0}
gear_right_hand: {fileID: 0}
hand_right: {fileID: 0}
hand_left: {fileID: 0}
shoulder_right: {fileID: 0}
shoulder_left: {fileID: 0}
- ears: {fileID: 0}
head: {fileID: 0}
mouth: {fileID: 0}
hair: {fileID: 0}
eyes: {fileID: 0}
torso: {fileID: 0}
gear_left_hand: {fileID: 0}
gear_right_hand: {fileID: 0}
hand_right: {fileID: 0}
hand_left: {fileID: 0}
shoulder_right: {fileID: 0}
shoulder_left: {fileID: 0}
--- !u!1 &3741846901656975085
GameObject:
m_ObjectHideFlags: 0

83
Assets/BossRoom/Scripts/Development/dgtest/CharacterSwap.cs


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();
}
}
}
}

11
Assets/BossRoom/Scripts/Development/dgtest/CharacterSwap.cs.meta


fileFormatVersion: 2
guid: a3048059d1dc86848a814084448ace11
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存