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
    
  
  
    
  | // This contains no error checking, which you want for such fragile code. | |
| // You also probably want to cache `mainWindow` if you call this often. | |
| static Rect GetMainWindowPosition() | |
| { | |
| var containerWindowType = typeof(EditorWindow).Assembly.GetType("UnityEditor.ContainerWindow"); | |
| var showModeField = containerWindowType.GetField("m_ShowMode", BindingFlags.Instance | BindingFlags.NonPublic); | |
| var mainWindow = Resources.FindObjectsOfTypeAll(containerWindowType).First(window => (int)showModeField.GetValue(window) == 4); | |
| var positionProperty = mainWindow.GetType().GetProperty("position", BindingFlags.Instance | BindingFlags.Public); | |
| return (Rect)positionProperty.GetValue(mainWindow, null); | |
| } | 
  
    
      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 Object GetMainEditorWindow() | |
| { | |
| var containerWindowType = typeof(EditorWindow).Assembly.GetType("UnityEditor.ContainerWindow"); | |
| var showModeField = containerWindowType.GetField("m_ShowMode", BindingFlags.Instance | BindingFlags.NonPublic); | |
| return Resources | |
| .FindObjectsOfTypeAll(containerWindowType) | |
| .First(window => (int)showModeField.GetValue(window) == 4); | |
| } | 
  
    
      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; | |
| /// <summary> | |
| /// Attribute to add to Vector3 and Vector3[] fields to make them draggable in the scene. | |
| /// </summary> | |
| public class Draggable : PropertyAttribute | |
| { | |
| } | 
  
    
      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() |