问题描述
我正在与一个非常小的团队一起进行一个小型激情项目。我们还不是最擅长C#编码的人,因此我们一直在尝试解决此问题,但运气还不够。
我们想要一个主菜单,其中摄像机根据您选择的选项在世界空间中从一个菜单动态移动到另一个菜单,然后进入该菜单,进入字符选择,其中字符发生的情况非常相似
到目前为止,我已经使用Cinemachine正常运行了主菜单,并且按预期工作。但是,当我选择角色时,我遇到了一些问题。我在屏幕上设置了字符选择控件,而不是在世界上使用,以简化操作,但是我一直在尝试弄清楚如何使箭头按钮在各个字符之间切换,同时也可以在到达最终字符时自动循环播放然后再次按下一步。我一直在尝试使用索引进行设置,但一直找不到要使Cinemachine达到我想要的功能所需的麻烦。
有人愿意提供帮助吗?我很感激! c:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class UITransitionManager : MonoBehavIoUr
{
public CinemachineVirtualCamera currentCamera;
public void Start()
{
currentCamera.Priority++;
}
public void UpdateCamera(CinemachineVirtualCamera target)
{
currentCamera.Priority--;
currentCamera = target;
currentCamera.Priority++;
}
}
我尝试进行字符选择的
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Cinemachine;
public class CSelectManager : MonoBehavIoUr
{
public GameObject[] contestantCams;
GameObject currentContestant;
int contestantIndex;
public Button nextCharacter;
public Button prevIoUsCharacter;
void Start()
{
Button next = nextCharacter.GetComponent<Button>();
next.onClick.AddListener(TaskOnClickNext);
Button prev = prevIoUsCharacter.GetComponent<Button>();
prev.onClick.AddListener(TaskOnClickPrev);
contestantIndex = 0;
currentContestant = contestantCams[0];
}
void TaskOnClickNext()
{
Debug.Log("Next character.");
contestantIndex++;
if (contestantIndex > (contestantCams.Length - 1))
{
contestantIndex = 0;
}
}
void TaskOnClickPrev()
{
Debug.Log("PrevIoUs character.");
contestantIndex--;
if(contestantIndex < 0)
{
contestantIndex = contestantCams.Length - 1;
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)