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
class_name Preferences | |
extends Resource | |
## # Usage example: | |
## var pref := Preferences.load_or_create("game_settings") | |
## mouse_sensitivity = pref.get_data("mouse_sensitivity", 1.0) | |
## # later, when changing the setting: | |
## pref.set_data("mouse_sensitivity", mouse_sensitivity) | |
static var _all:Dictionary |
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 | |
extends Node | |
@export var hammers:Array = [ 0, 0, 0 ] | |
func _get(property:StringName) -> Variant: | |
if property.begins_with("hammer_type"): | |
return hammers[int(str(property))] | |
match property: | |
&"hammer_count": return hammers.size() |
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.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.TerrainUtils; | |
namespace RatKing { | |
public class ShowTerrainHeightsOfBounds : MonoBehaviour { | |
void Awake() { | |
var showSeconds = 15f; |
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 UnityEditor; | |
using UnityEngine; | |
namespace RatKing { | |
// Usage: Put this file into an Editor folder in your Unity project | |
// When creating a new neighbour tile for terrain, select it and then choose | |
// "Tools -> Terrain -> Fill Terrain Height by Neighbours" - it will flatten the | |
// tile and move the ground to the origin XZ plane. NO UNDO!!! So be careful. |
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; | |
using System.Reflection; | |
using System.Collections.Generic; | |
// Usage: | |
// [ResetStatics(nameof(BooleanField))] | |
// public class MyClass : MonoBehaviour { | |
// public static bool BooleanField; | |
// // ... | |
// } |
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 UnityEngine; | |
namespace RatKing { | |
public static class ExtensionMethods { | |
public static Vector2 ToVec2(this Vector3 v) { return new Vector2(v.x, v.y); } | |
public static Vector3 ToVec3(this Vector2 v, float z = 0f) { return new Vector3(v.x, v.y, z); } | |
public static Vector2 WithX(this Vector2 v, float x) { v.x = x; return v; } // "this" on structs is always by value, never by reference | |
public static Vector2 WithY(this Vector2 v, float y) { v.y = y; return v; } // thus the methods only edit a copy and return a copy |