隐藏和返回功能

This commit is contained in:
shenjianxing 2025-02-14 08:58:46 +08:00
parent 194672f17c
commit d101ab8565
3 changed files with 21 additions and 3 deletions

View File

@ -3,7 +3,6 @@ using QFramework.Example;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
using XMLTool; using XMLTool;
@ -29,6 +28,8 @@ public class Body3DController : MonoSingleton<Body3DController>
public Status status = Status.Normal; public Status status = Status.Normal;
private Vector2 mouseDownPosition; // ¼Ç¼Êó±ê°´ÏÂʱµÄλÖà private Vector2 mouseDownPosition; // ¼Ç¼Êó±ê°´ÏÂʱµÄλÖÃ
Stack<GameObject> activeObjs = new Stack<GameObject>();
public override void OnSingletonInit() public override void OnSingletonInit()
{ {
base.OnSingletonInit(); base.OnSingletonInit();
@ -75,6 +76,8 @@ public class Body3DController : MonoSingleton<Body3DController>
} }
} }
public void SetStatus(Status status, bool isAdd) public void SetStatus(Status status, bool isAdd)
{ {
if (isAdd) if (isAdd)
@ -92,7 +95,21 @@ public class Body3DController : MonoSingleton<Body3DController>
return (this.status & status) == status; return (this.status & status) == status;
} }
public void AddActiveObj(GameObject obj)
{
activeObjs.Push(obj);
}
public GameObject PopActiveObj()
{
if (activeObjs.Count > 0)
{
return activeObjs.Pop();
}
else
{
return null;
}
}
public void Active(bool isActive) public void Active(bool isActive)
{ {

View File

@ -39,6 +39,7 @@ public class Body3DOjbItem : MonoBehaviour
if (isOn == true) if (isOn == true)
{ {
gameObject.SetActive(false); gameObject.SetActive(false);
Body3DController.Instance.AddActiveObj(gameObject);
} }
} }
else else

View File

@ -33,7 +33,7 @@ namespace QFramework.Example
ActiveBack.onClick.AddListener(() => ActiveBack.onClick.AddListener(() =>
{ {
Body3DController.Instance.PopActiveObj()?.gameObject.SetActive(true);
}); });
} }