mirror of
https://github.com/BotChain-Robots/ui.git
synced 2026-07-08 15:07:22 +02:00
Pipeline saving and View popup window added
Made-with: Cursor
This commit is contained in:
50
Assets/DiscoverOverlayController.cs
Normal file
50
Assets/DiscoverOverlayController.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DiscoverOverlayController : MonoBehaviour
|
||||
{
|
||||
public GameObject overlayPanel;
|
||||
public RectTransform overlayContent;
|
||||
|
||||
public void ShowOverlay()
|
||||
{
|
||||
if (overlayPanel != null)
|
||||
{
|
||||
EnsureScrollRect();
|
||||
overlayPanel.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void HideOverlay()
|
||||
{
|
||||
ClearContent();
|
||||
if (overlayPanel != null)
|
||||
overlayPanel.SetActive(false);
|
||||
}
|
||||
|
||||
void EnsureScrollRect()
|
||||
{
|
||||
if (overlayContent == null) return;
|
||||
var scrollArea = overlayContent.parent;
|
||||
if (scrollArea == null) return;
|
||||
var scrollGo = scrollArea.gameObject;
|
||||
if (scrollGo.GetComponent<Mask>() == null)
|
||||
scrollGo.AddComponent<Mask>().showMaskGraphic = false;
|
||||
var sr = scrollGo.GetComponent<ScrollRect>();
|
||||
if (sr == null)
|
||||
{
|
||||
sr = scrollGo.AddComponent<ScrollRect>();
|
||||
sr.horizontal = false;
|
||||
sr.vertical = true;
|
||||
sr.content = overlayContent;
|
||||
sr.movementType = ScrollRect.MovementType.Clamped;
|
||||
}
|
||||
}
|
||||
|
||||
void ClearContent()
|
||||
{
|
||||
if (overlayContent == null) return;
|
||||
for (int i = overlayContent.childCount - 1; i >= 0; i--)
|
||||
Destroy(overlayContent.GetChild(i).gameObject);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user