-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
## [0.2.0] - 2020-08-20 | ||
- Added a nice Sidebar fully configurable via project settings. | ||
|
||
## [0.1.0] - 2020-08-20 | ||
- Init. Only a couple of menu additions: Assets/Duplicate and GameObject/Group. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using UnityEngine; | ||
|
||
namespace XT.Base { | ||
|
||
internal static partial class Extensions { | ||
|
||
public static Color ToColor(this int rgba) { | ||
byte r = (byte)((rgba & 0xFF000000) >> 24); | ||
byte g = (byte)((rgba & 0x00FF0000) >> 16); | ||
byte b = (byte)((rgba & 0x0000FF00) >> 8); | ||
byte a = (byte)(rgba & 0x000000FF); | ||
return new Color32(r, g, b, a); | ||
} | ||
|
||
public static int ToRGBA(this Color color) { | ||
int r = (int)(color.r * 255); | ||
int g = (int)(color.g * 255); | ||
int b = (int)(color.b * 255); | ||
int a = (int)(color.a * 255); | ||
return r << 24 | g << 16 | b << 8 | a; | ||
} | ||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using System.Reflection; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace XT.Base { | ||
|
||
internal static partial class Extensions { | ||
|
||
class EditorWindowR : EditorType { | ||
|
||
static Type type = typeof(EditorWindow); | ||
public static PropertyInfo dockedProperty = type.GetNonPublicProperty("docked"); | ||
public static FieldInfo parentField = type.GetNonPublicField("m_Parent"); | ||
|
||
} | ||
|
||
public static object GetParent(this EditorWindow window) { | ||
return EditorWindowR.parentField?.GetValue(window); | ||
} | ||
|
||
public static bool IsDocked(this EditorWindow window) { | ||
return (bool)EditorWindowR.dockedProperty?.GetValue(window); | ||
} | ||
|
||
public static Rect GetPosition(this EditorWindow window) { | ||
object dockArea = window.GetParent(); | ||
return (Rect)ViewR.Wrap(dockArea).position; | ||
} | ||
|
||
public static Rect GetWindowPosition(this EditorWindow window) { | ||
object dockArea = window.GetParent(); | ||
return (Rect)ViewR.Wrap(dockArea).windowPosition; | ||
} | ||
|
||
public static float GetWidth(this EditorWindow window) { | ||
object dockArea = window.GetParent(); | ||
Rect p = (Rect)ViewR.Wrap(dockArea).windowPosition; | ||
return p.width; | ||
} | ||
|
||
public static void SetWidth(this EditorWindow window, float width) { | ||
object dockArea = window.GetParent(); | ||
Rect p = (Rect)ViewR.Wrap(dockArea).position; | ||
p.width = width; | ||
ViewR.Wrap(dockArea).position = p; | ||
object dockAreaParent = ViewR.Wrap(dockArea).parent; | ||
ViewR.Wrap(dockAreaParent).Reflow(); | ||
} | ||
|
||
public static bool IsFloating(this EditorWindow window) { | ||
object parent = window.GetParent(); | ||
if (parent == null) { | ||
return true; | ||
} | ||
parent = ViewR.Wrap(parent).parent; | ||
if (parent == null) { | ||
return true; | ||
} | ||
parent = ViewR.Wrap(parent).parent; | ||
return parent == null; | ||
} | ||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using UObject = UnityEngine.Object; | ||
|
||
namespace XT.Base { | ||
|
||
internal static partial class Extensions { | ||
|
||
public static void DestroyImmediate(this UObject obj) { | ||
if (obj != null) { | ||
UObject.DestroyImmediate(obj); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
|
||
namespace XT.Base { | ||
|
||
internal static partial class Extensions { | ||
|
||
public static bool IsNullOrEmpty(this string s) { | ||
return String.IsNullOrEmpty(s); | ||
} | ||
|
||
public static bool ContainsIgnoreCase(this string s, string text) { | ||
return s.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0; | ||
} | ||
|
||
public static bool EqualsIgnoreCase(this string s, string text) { | ||
return s.Equals(text, StringComparison.CurrentCultureIgnoreCase); | ||
} | ||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using BF = System.Reflection.BindingFlags; | ||
|
||
namespace XT.Base { | ||
|
||
internal static partial class Extensions { | ||
|
||
public static FieldInfo GetNonPublicField(this Type type, string name) { | ||
return type.GetField(name, BF.Instance | BF.Static | BF.NonPublic); | ||
} | ||
|
||
public static PropertyInfo GetNonPublicProperty(this Type type, string name) { | ||
return type.GetProperty(name, BF.Instance | BF.Static | BF.NonPublic); | ||
} | ||
|
||
public static MethodInfo GetNonPublicMethod(this Type type, string name) { | ||
return type.GetMethod(name, BF.Instance | BF.Static | BF.NonPublic); | ||
} | ||
|
||
public static MethodInfo GetNonPublicMethod(this Type type, string name, Type[] types) { | ||
return type.GetMethod(name, BF.Instance | BF.Static | BF.NonPublic, null, types, null); | ||
} | ||
|
||
public static bool IsGenericList(this Type type) { | ||
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>); | ||
} | ||
|
||
public static FieldInfo[] GetAllFields(this Type type) { | ||
return type.GetFields(BF.Instance | BF.Static | BF.Public| BF.NonPublic); | ||
} | ||
|
||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace XT.Base { | ||
|
||
internal class ContainerWindowR : EditorType { | ||
|
||
ContainerWindowR() {} | ||
|
||
static ContainerWindowR instance = new ContainerWindowR(); | ||
|
||
object containerWindow; | ||
|
||
public static ContainerWindowR Wrap(object containerWindow) { | ||
instance.containerWindow = containerWindow; | ||
return instance; | ||
} | ||
|
||
static Type type = GetType("ContainerWindow"); | ||
static PropertyInfo rootSplitViewProperty = type?.GetProperty("rootSplitView"); | ||
|
||
public object rootSplitView { | ||
get => rootSplitViewProperty?.GetValue(containerWindow); | ||
} | ||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Reflection; | ||
using UnityEngine; | ||
|
||
namespace XT.Base { | ||
|
||
internal class DockAreaR : EditorType { | ||
|
||
DockAreaR() { } | ||
|
||
static DockAreaR instance = new DockAreaR(); | ||
|
||
object dockArea; | ||
|
||
public static DockAreaR Wrap(object dockArea) { | ||
instance.dockArea = dockArea; | ||
return instance; | ||
} | ||
|
||
public static readonly Type type = GetType("DockArea"); | ||
static FieldInfo dragSourceField = type?.GetNonPublicField("s_OriginalDragSource"); | ||
static PropertyInfo windowProperty = type?.GetProperty("window"); | ||
static MethodInfo SetActualViewPositionMethod = type?.GetMethod("SetActualViewPosition"); | ||
|
||
public static object dragSource { | ||
get => dragSourceField.GetValue(null); | ||
set => dragSourceField.SetValue(null, value); | ||
} | ||
|
||
public object window { | ||
get => windowProperty?.GetValue(dockArea); | ||
} | ||
|
||
public void SetActualViewPosition(Rect rect) { | ||
SetActualViewPositionMethod?.Invoke(dockArea, new object[] { rect } ); | ||
} | ||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace XT.Base { | ||
|
||
internal class DropInfoR : EditorType { | ||
|
||
DropInfoR() { } | ||
|
||
static DropInfoR instance = new DropInfoR(); | ||
|
||
object dropInfo; | ||
|
||
public static DropInfoR Wrap(object dropInfo) { | ||
instance.dropInfo = dropInfo; | ||
return instance; | ||
} | ||
|
||
static Type type = GetType("DropInfo"); | ||
static FieldInfo dropAreaField = type?.GetField("dropArea"); | ||
|
||
public object dropArea { | ||
get => dropAreaField.GetValue(dropInfo); | ||
} | ||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.