using System.Collections; using System.Collections.Generic; using Godot; namespace Rokojori { public class Unique 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; if ( rootWindow == null ) { if ( Engine.IsEditorHint() ) { rootWindow = EditorInterface.Singleton.GetEditedSceneRoot(); } else { return null; } } _singleton = Nodes.GetAnyChild( rootWindow ); if ( _singleton == null ) { if ( Engine.IsEditorHint() ) { rootWindow = EditorInterface.Singleton.GetEditedSceneRoot(); _singleton = Nodes.GetAnyChild( rootWindow ); } } return _singleton; } } }