using Godot; // This is identical to the GDScript version, yet it doesn't work. [Tool] public partial class Viewport25D : Control { private int zoomLevel = 0; private bool isPanning = false; private Vector2 panCenter; private Vector2 viewportCenter; private int viewModeIndex = 0; // The type or namespace name 'EditorInterface' could not be found (are you missing a using directive or an assembly reference?) // No idea why this error shows up in VS Code. It builds fine... public EditorInterface editorInterface; // Set in node25d_plugin.gd private bool moving = false; private SubViewport viewport2d; private SubViewport viewportOverlay; private ButtonGroup viewModeButtonGroup; private Label zoomLabel; private PackedScene gizmo25dScene; public async override void _Ready() { // Give Godot a chance to fully load the scene. Should take two frames. await ToSignal(GetTree(), "idle_frame"); await ToSignal(GetTree(), "idle_frame"); var editedSceneRoot = GetTree().EditedSceneRoot; if (editedSceneRoot == null) { // Godot hasn't finished loading yet, so try loading the plugin again. //editorInterface.SetPluginEnabled("node25d", false); //editorInterface.SetPluginEnabled("node25d", true); return; } // Alright, we're loaded up. Now check if we have a valid world and assign it. var world2d = editedSceneRoot.GetViewport().World2d; if (world2d == GetViewport().World2d) { return; // This is the MainScreen25D scene opened in the editor! } viewport2d.World2d = world2d; // Onready vars. viewport2d = GetNode("Viewport2D"); viewportOverlay = GetNode("ViewportOverlay"); viewModeButtonGroup = GetParent().GetNode("TopBar").GetNode("ViewModeButtons").GetNode