Added a way to kill children

This commit is contained in:
Pasha Bibko
2026-01-13 10:54:09 +00:00
parent 37e4ee8273
commit eae7b615d6
6 changed files with 96 additions and 2 deletions

View File

@@ -2,6 +2,9 @@
{
public class BasicWindow : WindowBase
{
public override void OnWindowClicked()
{
Destroy(gameObject);
}
}
}

View File

@@ -4,11 +4,14 @@ namespace InterfaceOff
{
public abstract class WindowBase : MonoBehaviour
{
public WindowInteractions Interactions { get; set; }
public WindowComponents Components { get; set; }
public void InstantiateWindowBase()
{
transform.position = CanvasManager.GetRandomPositionOnCanvas();
}
public virtual void OnWindowClicked() { }
}
}

View File

@@ -0,0 +1,12 @@
using UnityEngine;
namespace InterfaceOff
{
public class WindowInteractions : MonoBehaviour
{
private WindowBase AttachedWindow { get; set; }
public void SetAttachedTo(WindowBase window) => AttachedWindow = window;
public void WindowClicked() => AttachedWindow.OnWindowClicked();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 60d964b1b6914933801eaa6783d62cd8
timeCreated: 1768301109

View File

@@ -49,6 +49,9 @@ namespace InterfaceOff
return;
}
windowBase.Interactions = go.GetComponent<WindowInteractions>();
windowBase.Interactions.SetAttachedTo(windowBase);
windowBase.Components = go.GetComponent<WindowComponents>();
windowBase.InstantiateWindowBase();
}