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
// MonoBehaviour | |
using UnityEngine; | |
public class MeshPreview : MonoBehaviour | |
{ | |
public Mesh mesh; | |
[Range(1, 1000)] public int previewHeight = 100; | |
public bool showSettings = 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
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
using System.Net.NetworkInformation; | |
using System.Net.Sockets; | |
using Unity.Netcode.Transports.UTP; | |
using UnityEngine; | |
namespace Unity.Netcode.Samples | |
{ |
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 override void OnInspectorGUI() | |
{ | |
DrawDefaultInspector(); | |
var script = (RandomMeshSelector)target; | |
if (GUILayout.Button("Change Random Seed")) | |
{ | |
serializedObject.FindProperty("m_RandomSeed").intValue = script.GenerateNewRandomSeed(); | |
serializedObject.ApplyModifiedProperties(); |
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
// MIT License | |
// Copyright 2023 Steffen Itterheim | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH TH |
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
// example usage of [ReadOnlyField] that displays a calculated/converted value | |
// calculated value is updated whenever underlying value(s) change(s) | |
using UnityEngine; | |
public class CalculatedFieldTest : MonoBehaviour | |
{ | |
private const float TargetFramerate = 60f; | |
[SerializeField] private int m_Ticks; | |
[SerializeField] [ReadOnlyField] private float m_CalculatedSeconds; |
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 CodeSmile | |
{ | |
public class PressEscapeToQuit : MonoBehaviour | |
{ | |
private void Update() | |
{ | |
if (Input.GetKeyDown(KeyCode.Escape)) | |
Application.Quit(); |
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 CodeSmile.EditorTests | |
{ | |
public static class GameObjectExt | |
{ | |
public static bool IsNullOrMissing(this GameObject instance) => instance == null || ReferenceEquals(instance, null); | |
} | |
} |
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 Domain | |
using UnityEngine; | |
namespace CodeSmile | |
{ | |
[ExecuteInEditMode] | |
public class DropToGround : MonoBehaviour | |
{ | |
[SerializeField] private bool m_SnapPosition; |
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 CodeSmile | |
{ | |
public static class RayExt | |
{ | |
const float MinDenominator = 0.00001f; | |
/// <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 Domain | |
// Usage: Add an instance of EditorInputState to an editor script, create the instance on Awake. | |
// Then call m_InputState.Update() in every On*GUI method you implement and then query the m_InputState | |
// wherever you need to test for input. | |
using System; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UIElements; |
OlderNewer