rj-action-library/Runtime/Godot/Root.cs

96 lines
1.5 KiB
C#
Raw Normal View History

2025-06-19 17:22:25 +00:00
using System;
2024-05-04 08:26:16 +00:00
using Godot;
namespace Rokojori
{
2024-07-26 09:26:24 +00:00
[Tool]
2024-05-04 08:26:16 +00:00
public partial class Root:Node
{
private static Root _singleton;
public override void _Ready()
{
_singleton = this;
}
public static SceneTree Tree()
{
2024-07-26 09:26:24 +00:00
if ( _singleton == null )
{
return null;
}
2024-05-04 08:26:16 +00:00
return _singleton.GetTree();
}
public static Window Window()
{
2024-07-26 09:26:24 +00:00
var tree = Tree();
if ( tree == null)
{
return null;
}
return tree.Root;
2024-05-04 08:26:16 +00:00
}
static Root Get()
2024-05-04 08:26:16 +00:00
{
var r = Window();
2024-05-04 08:26:16 +00:00
return _singleton;
}
2025-06-19 17:22:25 +00:00
#if TOOLS
public override void _Process( double delta )
{
if ( ! Engine.IsEditorHint() )
{
return;
}
CheckWarnings();
}
int step = 0;
void CheckWarnings()
{
var walker = NodesWalker.Get();
for ( int i = 0; i < numNodeTests; i++ )
{
if ( _iterationNode == null || ! IsInstanceValid( _iterationNode ) )
{
_iterationNode = EditorInterface.Singleton.GetEditedSceneRoot();
}
else
{
_iterationNode = walker.NextNode( _iterationNode );
}
UpdateWarning( _iterationNode );
}
}
Node _iterationNode = null;
int numNodeTests = 100;
void UpdateWarning( Node n )
{
if ( n == null )
{
return;
}
n.UpdateConfigurationWarnings();
}
#endif
2024-05-04 08:26:16 +00:00
}
}