Added a way to kill children
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
{
|
||||
public class BasicWindow : WindowBase
|
||||
{
|
||||
|
||||
public override void OnWindowClicked()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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() { }
|
||||
}
|
||||
}
|
||||
|
||||
12
Assets/Scripts/WindowInteractions.cs
Normal file
12
Assets/Scripts/WindowInteractions.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/WindowInteractions.cs.meta
Normal file
3
Assets/Scripts/WindowInteractions.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60d964b1b6914933801eaa6783d62cd8
|
||||
timeCreated: 1768301109
|
||||
@@ -49,6 +49,9 @@ namespace InterfaceOff
|
||||
return;
|
||||
}
|
||||
|
||||
windowBase.Interactions = go.GetComponent<WindowInteractions>();
|
||||
windowBase.Interactions.SetAttachedTo(windowBase);
|
||||
|
||||
windowBase.Components = go.GetComponent<WindowComponents>();
|
||||
windowBase.InstantiateWindowBase();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user