37 lines
621 B
C#
37 lines
621 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
using Godot;
|
|
|
|
namespace Rokojori
|
|
{
|
|
public class Unique<N> where N:Node
|
|
{
|
|
private static N _singleton;
|
|
|
|
public static N Get( Node n = null )
|
|
{
|
|
if ( _singleton != null )
|
|
{
|
|
return _singleton;
|
|
}
|
|
|
|
var rootWindow = n == null ? Root.Window() : n.Owner;
|
|
|
|
// RJLog.Log( "ROOT", rootWindow );
|
|
|
|
if ( rootWindow == null )
|
|
{
|
|
return null;
|
|
}
|
|
|
|
_singleton = Nodes.GetAnyChild<N>( rootWindow );
|
|
|
|
// RJLog.Log( "_singleton", _singleton );
|
|
|
|
return _singleton;
|
|
}
|
|
|
|
|
|
}
|
|
} |