This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Godot; | |
using System; | |
[GlobalClass] | |
public partial class SafeAreaContainer : MarginContainer | |
{ | |
private bool _isUpdating; | |
private Rect2I _safeArea; | |
private Timer _mobileOrientationListenerTimer; | |
private bool _left = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static partial class PackedSceneExtension | |
{ | |
public static Variant? GetNodePropertyValue(this PackedScene packedScene, int nodeIndex, StringName propertyName) | |
{ | |
SceneState sceneState = packedScene.GetState(); | |
int propertyCount = sceneState.GetNodePropertyCount(nodeIndex); | |
for (int propertyIndex = 0; propertyIndex < propertyCount; propertyIndex++) | |
{ | |
if (sceneState.GetNodePropertyName(nodeIndex, propertyIndex) == propertyName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@tool | |
class_name Trail2D extends Node2D | |
@export var duration_sec: float = 0.2: | |
set(value): | |
_line.clear_points() | |
_point_times.clear() | |
duration_sec = value | |
@export var width: int = 10: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
public static partial class Node2DExtension | |
{ | |
public static Rect2 GetCalculatedBounds(this Node2D node2D) | |
{ | |
var rect = new Rect2(); | |
var children = node2D.GetChildren().ToList(); | |
while (children.Count > 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shader_type canvas_item; | |
uniform vec3 border_color: source_color = vec3(0); | |
uniform float border_width: hint_range(0, 10) = 0; | |
uniform bool circle = false; | |
void fragment() { | |
float center = 0.5; | |
float border_width_uv = border_width * min(TEXTURE_PIXEL_SIZE.x, TEXTURE_PIXEL_SIZE.y); | |
float border_start = center - border_width_uv; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shader_type canvas_item; | |
uniform vec4 border_color: source_color = vec4(1.0); | |
uniform float border_width: hint_range(0, 10) = 0; | |
void fragment() { | |
float border_width_uv = border_width * max(TEXTURE_PIXEL_SIZE.x, TEXTURE_PIXEL_SIZE.y); | |
if (step(0.5 - border_width_uv, abs(UV.x - 0.5)) == 1.0 || | |
step(0.5 - border_width_uv, abs(UV.y - 0.5)) == 1.0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shader_type canvas_item; | |
uniform vec4 border_color: source_color = vec4(1.0); | |
uniform float border_width: hint_range(0, 10) = 0; | |
void fragment() { | |
float alpha = step(length(UV - vec2(0.5, 0.5)), 0.5); | |
if (alpha > 0.0) { | |
float border_width_uv = border_width * max(TEXTURE_PIXEL_SIZE.x, TEXTURE_PIXEL_SIZE.y); | |
if (step(0.5 - border_width_uv, length(UV - vec2(0.5, 0.5))) == 1.0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[GlobalClass, Tool] | |
public partial class Region : CollisionPolygon2D | |
{ | |
private List<Vector2> _editorGlobalPolygon; | |
/// <summary> | |
/// When enabled, the polygon is stored as global space. | |
/// When disabled, the global polygon is restored as local space. | |
/// This allows workflow: enable property, move position, disable property. | |
/// </summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static partial class GodotObjectExtension | |
{ | |
public static GodotObject NewWithScript(this GodotObject obj, Variant? script) | |
{ | |
script ??= new Variant(); | |
ulong id = obj.GetInstanceId(); | |
obj.SetScript(script.Value); | |
return GodotObject.InstanceFromId(id); | |
} |
NewerOlder