2d0aaa98aa
- 重写 PageController.cs,为所有按钮回调添加完整 Debug.Log - 自动修复 _btnFixationBack:未赋值时自动查找 FixationPanel/BtnBack - 自动修复 _btnExperimentBack:未赋值时自动查找 ExperimentPanel/Navbar/BtnBack - 删除失效的 Canvas 根级冗余 BtnFixationBack - 添加 3D 角色模型资源(man/woman 模型、动画、TextMesh Pro) - 添加 ExperimentPanel UI 资源和 TrainingBackground 素材 测试方法:进入 Play 模式,查看 Console 以验证每个按钮的绑定状态和点击回调是否正常触发。
85 lines
3.3 KiB
C#
Executable File
85 lines
3.3 KiB
C#
Executable File
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
|
|
namespace TMPro.Examples
|
|
{
|
|
|
|
public class TMPro_InstructionOverlay : MonoBehaviour
|
|
{
|
|
|
|
public enum FpsCounterAnchorPositions { TopLeft, BottomLeft, TopRight, BottomRight };
|
|
|
|
public FpsCounterAnchorPositions AnchorPosition = FpsCounterAnchorPositions.BottomLeft;
|
|
|
|
private const string instructions = "Camera Control - <#ffff00>Shift + RMB\n</color>Zoom - <#ffff00>Mouse wheel.";
|
|
|
|
private TextMeshPro m_TextMeshPro;
|
|
private TextContainer m_textContainer;
|
|
private Transform m_frameCounter_transform;
|
|
private Camera m_camera;
|
|
|
|
//private FpsCounterAnchorPositions last_AnchorPosition;
|
|
|
|
void Awake()
|
|
{
|
|
if (!enabled)
|
|
return;
|
|
|
|
m_camera = Camera.main;
|
|
|
|
GameObject frameCounter = new GameObject("Frame Counter");
|
|
m_frameCounter_transform = frameCounter.transform;
|
|
m_frameCounter_transform.parent = m_camera.transform;
|
|
m_frameCounter_transform.localRotation = Quaternion.identity;
|
|
|
|
|
|
m_TextMeshPro = frameCounter.AddComponent<TextMeshPro>();
|
|
m_TextMeshPro.font = Resources.Load<TMP_FontAsset>("Fonts & Materials/LiberationSans SDF");
|
|
m_TextMeshPro.fontSharedMaterial = Resources.Load<Material>("Fonts & Materials/LiberationSans SDF - Overlay");
|
|
|
|
m_TextMeshPro.fontSize = 30;
|
|
|
|
m_TextMeshPro.isOverlay = true;
|
|
m_textContainer = frameCounter.GetComponent<TextContainer>();
|
|
|
|
Set_FrameCounter_Position(AnchorPosition);
|
|
//last_AnchorPosition = AnchorPosition;
|
|
|
|
m_TextMeshPro.text = instructions;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Set_FrameCounter_Position(FpsCounterAnchorPositions anchor_position)
|
|
{
|
|
|
|
switch (anchor_position)
|
|
{
|
|
case FpsCounterAnchorPositions.TopLeft:
|
|
//m_TextMeshPro.anchor = AnchorPositions.TopLeft;
|
|
m_textContainer.anchorPosition = TextContainerAnchors.TopLeft;
|
|
m_frameCounter_transform.position = m_camera.ViewportToWorldPoint(new Vector3(0, 1, 100.0f));
|
|
break;
|
|
case FpsCounterAnchorPositions.BottomLeft:
|
|
//m_TextMeshPro.anchor = AnchorPositions.BottomLeft;
|
|
m_textContainer.anchorPosition = TextContainerAnchors.BottomLeft;
|
|
m_frameCounter_transform.position = m_camera.ViewportToWorldPoint(new Vector3(0, 0, 100.0f));
|
|
break;
|
|
case FpsCounterAnchorPositions.TopRight:
|
|
//m_TextMeshPro.anchor = AnchorPositions.TopRight;
|
|
m_textContainer.anchorPosition = TextContainerAnchors.TopRight;
|
|
m_frameCounter_transform.position = m_camera.ViewportToWorldPoint(new Vector3(1, 1, 100.0f));
|
|
break;
|
|
case FpsCounterAnchorPositions.BottomRight:
|
|
//m_TextMeshPro.anchor = AnchorPositions.BottomRight;
|
|
m_textContainer.anchorPosition = TextContainerAnchors.BottomRight;
|
|
m_frameCounter_transform.position = m_camera.ViewportToWorldPoint(new Vector3(1, 0, 100.0f));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|