feat: 流程重排—Shoe→chanraotuibu→ping004→逐点模型→chanrao
This commit is contained in:
@@ -4,20 +4,17 @@ public class PingClickHandler : MonoBehaviour
|
||||
{
|
||||
public GameObject chanraoObject, nextPing;
|
||||
public int pingIndex;
|
||||
|
||||
private MeshRenderer _modelRenderer, _outlineMesh;
|
||||
private bool _clickedOnce;
|
||||
private static int _firstClickCount;
|
||||
private bool _modelShown;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_modelRenderer = GetComponent<MeshRenderer>();
|
||||
if (_modelRenderer == null) _modelRenderer = GetComponentInChildren<MeshRenderer>();
|
||||
if (_modelRenderer != null) _modelRenderer.enabled = false;
|
||||
foreach (var r in GetComponentsInChildren<Renderer>(true)) r.enabled = false;
|
||||
if (GetComponent<Collider>() == null) gameObject.AddComponent<SphereCollider>().radius = 0.5f;
|
||||
CreateOutlineMesh();
|
||||
_clickedOnce = false;
|
||||
_modelShown = false;
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(BlinkOutline());
|
||||
}
|
||||
@@ -28,7 +25,9 @@ public class PingClickHandler : MonoBehaviour
|
||||
var mf = GetComponent<MeshFilter>();
|
||||
if (mf == null) mf = GetComponentInChildren<MeshFilter>();
|
||||
if (mf == null || mf.sharedMesh == null) return;
|
||||
var mat = new Material(Shader.Find("Custom/OutlineUnlit"));
|
||||
var shader = Shader.Find("Custom/OutlineUnlit");
|
||||
if (shader == null) return;
|
||||
var mat = new Material(shader);
|
||||
mat.SetColor("_OutlineColor", new Color(0.2f, 0.5f, 1f, 1f));
|
||||
mat.SetColor("_MainColor", new Color(0, 0, 0, 0));
|
||||
mat.SetFloat("_OutlineWidth", 0.1f);
|
||||
@@ -43,52 +42,41 @@ public class PingClickHandler : MonoBehaviour
|
||||
{
|
||||
if (_outlineMesh != null) _outlineMesh.enabled = true;
|
||||
yield return new WaitForSeconds(0.4f);
|
||||
while (true)
|
||||
{
|
||||
if (_outlineMesh != null) _outlineMesh.enabled = !_outlineMesh.enabled;
|
||||
yield return new WaitForSeconds(0.4f);
|
||||
}
|
||||
while (true) { if (_outlineMesh != null) _outlineMesh.enabled = !_outlineMesh.enabled; yield return new WaitForSeconds(0.4f); }
|
||||
}
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
// touchArray 优先
|
||||
foreach (var c in Object.FindObjectsOfType<Camera>())
|
||||
{
|
||||
if (!c.enabled) continue;
|
||||
foreach (var h in Physics.RaycastAll(c.ScreenPointToRay(Input.mousePosition)))
|
||||
if (h.collider != null && h.collider.transform.parent != null && h.collider.transform.parent.name == "touchArray") return;
|
||||
if (h.collider?.transform.parent?.name == "touchArray") return;
|
||||
}
|
||||
|
||||
if (_firstClickCount < 4)
|
||||
if (!_modelShown)
|
||||
{
|
||||
if (_clickedOnce) return;
|
||||
_clickedOnce = true; _firstClickCount++;
|
||||
// 首次点击: 显示模型,隐藏边框,激活下一个 ping
|
||||
_modelShown = true;
|
||||
StopAllCoroutines();
|
||||
if (_modelRenderer != null) _modelRenderer.enabled = true;
|
||||
foreach (var r in GetComponentsInChildren<Renderer>(true)) r.enabled = true;
|
||||
if (_outlineMesh != null) _outlineMesh.enabled = false;
|
||||
if (nextPing != null) nextPing.SetActive(true);
|
||||
Debug.Log($"[PingClick] {name} 第1击 ({_firstClickCount}/4)");
|
||||
if (_firstClickCount >= 4)
|
||||
{
|
||||
var mi = GameObject.Find("manInjury");
|
||||
if (mi != null) { var ct = mi.transform.Find("chanraotuibu"); if (ct != null) { ct.gameObject.SetActive(true); Debug.Log("[PingClick] chanraotuibu 激活"); } }
|
||||
}
|
||||
var sm = FindObjectOfType<StepManager>(); if (sm != null) sm.RecordPingStep(pingIndex, false);
|
||||
Debug.Log($"[PingClick] {name} 模型显示, 激活 {nextPing?.name}");
|
||||
var sm = FindObjectOfType<StepManager>();
|
||||
if (sm != null) sm.RecordPingStep(pingIndex, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_clickedOnce) return;
|
||||
if (chanraoObject != null) chanraoObject.SetActive(true);
|
||||
StopAllCoroutines();
|
||||
if (_modelRenderer != null) _modelRenderer.enabled = false;
|
||||
if (_outlineMesh != null) _outlineMesh.enabled = false;
|
||||
// 模型已显示: 点击显示 chanrao
|
||||
if (chanraoObject != null) { chanraoObject.SetActive(true); Debug.Log($"[PingClick] {name} → {chanraoObject.name}"); }
|
||||
gameObject.SetActive(false);
|
||||
Debug.Log($"[PingClick] {name} 第2击");
|
||||
var sm = FindObjectOfType<StepManager>(); if (sm != null) sm.RecordPingStep(pingIndex, true);
|
||||
var sm = FindObjectOfType<StepManager>();
|
||||
if (sm != null) sm.RecordPingStep(pingIndex, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void ReEnableBorder() { if (_outlineMesh != null) { _outlineMesh.enabled = true; StopAllCoroutines(); StartCoroutine(BlinkOutline()); } }
|
||||
public void UndoSecondClick() { if (!_clickedOnce) return; _clickedOnce = false; _firstClickCount--; gameObject.SetActive(true); if (_modelRenderer != null) _modelRenderer.enabled = false; StopAllCoroutines(); StartCoroutine(BlinkOutline()); }
|
||||
public void UndoShow() { gameObject.SetActive(false); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user