Skip to content

Commit

Permalink
Updated to Unity 2020.1.15f1 version; Added Rainbow Folders 2 and Enh…
Browse files Browse the repository at this point in the history
…janced Hierarchy 2.0 plugins.
  • Loading branch information
SMARTIUM committed Nov 28, 2020
1 parent 29720b4 commit 3ff9264
Show file tree
Hide file tree
Showing 169 changed files with 6,145 additions and 0 deletions.
Binary file modified Assets/.DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Enhanced Hierarchy.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/Enhanced Hierarchy/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions Assets/Enhanced Hierarchy/Editor/After.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Diagnostics;
using UnityEditor;

namespace EnhancedHierarchy {
/// <summary>Utility class for running async tasks within the main thread.</summary>
public static class After {

/// <summary>Wait for a condition to become true, then executes the callback.</summary>
/// <param name="condition">Function that will be called every frame that returns whether to invoke the callback or not.</param>
/// <param name="callback">The callback to be called when the condition becomes true.</param>
/// <param name="timeoutMs">Maximum time to wait in milliseconds before cancelling the callback.</param>
public static void Condition(Func<bool> condition, Action callback, double timeoutMs = 0d) {
var update = new EditorApplication.CallbackFunction(() => { });
var timeoutsAt = EditorApplication.timeSinceStartup + (timeoutMs / 1000d);
var stack = new StackFrame(1, true);

update = () => {
if (timeoutMs > 0d && EditorApplication.timeSinceStartup >= timeoutsAt) {
EditorApplication.update -= update;
UnityEngine.Debug.LogErrorFormat("Condition timedout at {0}:{1}", stack.GetFileName(), stack.GetFileLineNumber());
return;
}

if (condition()) {
EditorApplication.update -= update;
callback();
}
};

EditorApplication.update += update;
}

/// <summary>Wait for the given amount of editor frames, then executes the callback.</summary>
/// <param name="frames">The number of frames to wait for.</param>
/// <param name="callback">The callback to be called after the specified frames.</param>
public static void Frames(int frames, Action callback) {
var f = 0;
Condition(() => f++ >= frames, callback);
}

/// <summary>Wait for the given time, then executes the callback.</summary>
/// <param name="milliseconds">How long to wait until calling the callback, in milliseconds.</param>
/// <param name="callback">The callback to be called after the specified time.</param>
public static void Milliseconds(double milliseconds, Action callback) {
var end = EditorApplication.timeSinceStartup + (milliseconds / 1000f);
Condition(() => EditorApplication.timeSinceStartup >= end, callback);
}

}
}
11 changes: 11 additions & 0 deletions Assets/Enhanced Hierarchy/Editor/After.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 109 additions & 0 deletions Assets/Enhanced Hierarchy/Editor/Disposables.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System;
using UnityEditor;
using UnityEditor.AnimatedValues;
using UnityEngine;

namespace EnhancedHierarchy {

public struct GUIBackgroundColor : IDisposable {
private readonly Color before;

public GUIBackgroundColor(Color color) {
before = GUI.backgroundColor;
GUI.backgroundColor = color;
}

public void Dispose() {
GUI.backgroundColor = before;
}
}

public struct GUIContentColor : IDisposable {
private readonly Color before;

public GUIContentColor(Color color) {
before = GUI.contentColor;
GUI.contentColor = color;
}

public void Dispose() {
GUI.contentColor = before;
}
}

public struct GUIColor : IDisposable {
private readonly Color before;

public GUIColor(Color color) {
before = GUI.color;
GUI.color = color;
}

public GUIColor(Color color, float alpha) {
before = GUI.color;
color.a = alpha;
GUI.color = color;
}

public void Dispose() {
GUI.color = before;
}
}

public sealed class GUIIndent : IDisposable {
public GUIIndent() {
EditorGUI.indentLevel++;
}

public GUIIndent(string label) {
EditorGUILayout.LabelField(label);
EditorGUI.indentLevel++;
}

public void Dispose() {
EditorGUI.indentLevel--;
EditorGUILayout.Separator();
}
}

public struct GUIEnabled : IDisposable {
private readonly bool before;

public GUIEnabled(bool enabled) {
before = GUI.enabled;
GUI.enabled = before && enabled;
}

public void Dispose() {
GUI.enabled = before;
}
}

public sealed class GUIFade : IDisposable {
private AnimBool anim;

public bool Visible { get; private set; }

public GUIFade() {
Visible = true;
}

public void SetTarget(bool target) {
if (anim == null) {
anim = new AnimBool(target);
anim.valueChanged.AddListener(() => {
if (EditorWindow.focusedWindow)
EditorWindow.focusedWindow.Repaint();
});
}

anim.target = target;
Visible = EditorGUILayout.BeginFadeGroup(anim.faded);
}

public void Dispose() {
EditorGUILayout.EndFadeGroup();
}
}

}
12 changes: 12 additions & 0 deletions Assets/Enhanced Hierarchy/Editor/Disposables.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Assets/Enhanced Hierarchy/Editor/EnhancedHierarchy.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "EnhancedHierarchyEditor",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3ff9264

Please sign in to comment.