This file contains hidden or 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 inside Editor.OnSceneGUI for Vector3 fields: | |
// | |
// foreach (var property in GetPropertiesWithAttribute<MyCustomAttribute>(serializedObject)) | |
// { | |
// Handles.Label(property.vector3Value, property.name); | |
// } | |
static IEnumerable<SerializedProperty> GetPropertiesWithAttribute<TAttribute>(SerializedObject serializedObject) | |
{ | |
var targetObjectType = serializedObject.targetObject.GetType(); |
This file contains hidden or 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
static Vector2 RandomPointOnUnitCircle() | |
{ | |
var angle = Random.Range(0f, Mathf.PI * 2); | |
var x = Mathf.Sin(angle); | |
var y = Mathf.Cos(angle); | |
return new Vector2(x, y); | |
} |
This file contains hidden or 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.Collections.Generic; | |
public class StateMachine | |
{ | |
public interface IState | |
{ | |
public void OnEnter(); | |
public void OnExit(); | |
} |
This file contains hidden or 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 UnityEngine; | |
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Struct)] | |
public class ConditionalEnableAttribute : PropertyAttribute | |
{ | |
public readonly string ConditionalPropertyName; | |
public ConditionalEnableAttribute(string conditionalPropertyName) | |
{ |
This file contains hidden or 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 Bounds GetBounds(this GameObject gameObject) | |
{ | |
var bounds = new Bounds(gameObject.transform.position, Vector3.zero); | |
var renderers = gameObject.GetComponentsInChildren<Renderer>(); | |
foreach (var renderer in renderers) | |
{ | |
bounds.Encapsulate(renderer.bounds); | |
} |
This file contains hidden or 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; | |
using Cinemachine; | |
using UnityEngine; | |
using UnityEngine.Playables; | |
using UnityEngine.Timeline; | |
[ExecuteInEditMode] | |
public class CinemachineBrainTimelineBinder : MonoBehaviour | |
{ | |
void Start() |
This file contains hidden or 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
/// <summary> | |
/// Modes that specify how the control points affect a Bezier curve. | |
/// </summary> | |
public enum BezierControlPointMode | |
{ | |
Aligned, | |
Free, | |
Mirrored, | |
} |
This file contains hidden or 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.IO; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
using UnityEditor; | |
using UnityEditor.AddressableAssets.Build; | |
using UnityEditor.AddressableAssets.Build.AnalyzeRules; | |
using UnityEditor.AddressableAssets.Settings; | |
using UnityEngine; |
This file contains hidden or 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; | |
using UnityEngine.XR.Interaction.Toolkit; | |
public class OffsetGrabInteractable : XRGrabInteractable | |
{ | |
Vector3 interactorPosition; | |
Quaternion interactorRotation; | |
protected override void OnSelectEntered(XRBaseInteractor interactor) | |
{ |