Skip to content

Commit

Permalink
Added Sidebar.
Browse files Browse the repository at this point in the history
  • Loading branch information
xeleh committed Apr 14, 2020
1 parent ab6e164 commit 33241f7
Show file tree
Hide file tree
Showing 207 changed files with 9,290 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
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.
8 changes: 8 additions & 0 deletions Editor/Base.meta

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

8 changes: 8 additions & 0 deletions Editor/Base/Extensions.meta

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

25 changes: 25 additions & 0 deletions Editor/Base/Extensions/Color.cs
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;
}

}

}
11 changes: 11 additions & 0 deletions Editor/Base/Extensions/Color.cs.meta

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

66 changes: 66 additions & 0 deletions Editor/Base/Extensions/EditorWindow.cs
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;
}

}

}
11 changes: 11 additions & 0 deletions Editor/Base/Extensions/EditorWindow.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 Editor/Base/Extensions/Object.cs
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);
}
}

}

}
11 changes: 11 additions & 0 deletions Editor/Base/Extensions/Object.cs.meta

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

21 changes: 21 additions & 0 deletions Editor/Base/Extensions/String.cs
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);
}

}

}
11 changes: 11 additions & 0 deletions Editor/Base/Extensions/String.cs.meta

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

37 changes: 37 additions & 0 deletions Editor/Base/Extensions/Type.cs
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);
}


}

}
11 changes: 11 additions & 0 deletions Editor/Base/Extensions/Type.cs.meta

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

8 changes: 8 additions & 0 deletions Editor/Base/Reflected.meta

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

28 changes: 28 additions & 0 deletions Editor/Base/Reflected/ContainerWindowR.cs
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);
}

}

}
11 changes: 11 additions & 0 deletions Editor/Base/Reflected/ContainerWindowR.cs.meta

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

40 changes: 40 additions & 0 deletions Editor/Base/Reflected/DockAreaR.cs
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 } );
}

}

}
11 changes: 11 additions & 0 deletions Editor/Base/Reflected/DockAreaR.cs.meta

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

28 changes: 28 additions & 0 deletions Editor/Base/Reflected/DropInfoR.cs
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);
}

}

}
11 changes: 11 additions & 0 deletions Editor/Base/Reflected/DropInfoR.cs.meta

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

Loading

0 comments on commit 33241f7

Please sign in to comment.