Added samples for burst and entities
This commit is contained in:
parent
2a354e7da5
commit
c1e7044561
25 changed files with 840 additions and 3 deletions
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "Module.NavigationTool.Editor.Entities",
|
||||
"rootNamespace": "Module.NavigationTool.Editor.Entities",
|
||||
"references": [
|
||||
"GUID:8339b3ce77cb32f489776d81010ad36c"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7f005006296b7aa41b589cd21e890d5c
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Samples~/SamplesToolbarEntities/Settings.meta
Normal file
8
Samples~/SamplesToolbarEntities/Settings.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b746b07b87c4e4340aed5ad6a7bc3b64
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
using Module.NavigationTool.Editor.Toolbar;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Entities.Toolbar
|
||||
{
|
||||
internal sealed class ToolbarEntitiesSettings : IToolbarSettings
|
||||
{
|
||||
public string Title => "Entities";
|
||||
|
||||
private const string PREF_PREFS_ENABLED = "ToolbarSettings.IsEntitiesEnabled";
|
||||
|
||||
public static bool IsEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_PREFS_ENABLED, false);
|
||||
set => EditorPrefs.SetBool(PREF_PREFS_ENABLED, value);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
IsEnabled = EditorGUILayout.Toggle("Enable Entities", IsEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1077d6399eff29247a55c20578a2df1c
|
||||
125
Samples~/SamplesToolbarEntities/ToolEntities.cs
Normal file
125
Samples~/SamplesToolbarEntities/ToolEntities.cs
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using Module.NavigationTool.Editor.Toolbar;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Entities.Toolbar
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class ToolEntities : AbstractToolbarDrawer
|
||||
{
|
||||
public override bool Visible => ToolbarEntitiesSettings.IsEnabled;
|
||||
public override bool Enabled => true;
|
||||
public override EToolbarPlacement Placement => EToolbarPlacement.Left;
|
||||
public override int Priority => (int)EToolbarPriority.Low;
|
||||
|
||||
protected override void Draw(Rect rect)
|
||||
{
|
||||
Styles.Initialize();
|
||||
|
||||
Rect rect0 = new Rect(rect.x, rect.y, 24f, rect.height);
|
||||
Rect rect1 = new Rect(rect0.xMax, rect.y, 24f, rect.height);
|
||||
Rect rect2 = new Rect(rect1.xMax, rect.y, 24f, rect.height);
|
||||
Rect rect3 = new Rect(rect2.xMax, rect.y, 24f, rect.height);
|
||||
Rect rect4 = new Rect(rect3.xMax, rect.y, 24f, rect.height);
|
||||
|
||||
if (GUI.Button(rect0, Styles.ICON_HIERARCHY, styles.button))
|
||||
ToggleWindow("HierarchyWindow");
|
||||
if (GUI.Button(rect1, Styles.ICON_COMPONENTS, styles.button))
|
||||
ToggleWindow("ComponentsWindow");
|
||||
if (GUI.Button(rect2, Styles.ICON_SYSTEMS, styles.button))
|
||||
ToggleWindow("SystemScheduleWindow");
|
||||
if (GUI.Button(rect3, Styles.ICON_ARCHETYPES, styles.button))
|
||||
ToggleWindow("ArchetypesWindow");
|
||||
if (GUI.Button(rect4, Styles.ICON_JOURNALING, styles.button))
|
||||
ToggleWindow("EntitiesJournalingWindow");
|
||||
|
||||
GUI.Label(rect0, Styles.LABEL_HIERARCHY, styles.labelCenter);
|
||||
GUI.Label(rect1, Styles.LABEL_COMPONENTS, styles.labelCenter);
|
||||
GUI.Label(rect2, Styles.LABEL_SYSTEMS, styles.labelCenter);
|
||||
GUI.Label(rect3, Styles.LABEL_ARCHETYPES, styles.labelCenter);
|
||||
GUI.Label(rect4, Styles.LABEL_JOURNALING, styles.labelCenter);
|
||||
}
|
||||
|
||||
public override float CalculateWidth()
|
||||
{
|
||||
return 120.0f;
|
||||
}
|
||||
|
||||
private void ToggleWindow(string typeName)
|
||||
{
|
||||
string fullname = "Unity.Entities.Editor." + typeName + ", Unity.Entities.Editor";
|
||||
Type type = Type.GetType(fullname, false, true);
|
||||
|
||||
if (type != null)
|
||||
{
|
||||
Object[] all = Resources.FindObjectsOfTypeAll(type);
|
||||
|
||||
if (all.Length != 0)
|
||||
{
|
||||
for (int i = 0; i < all.Length; i++)
|
||||
{
|
||||
if (all[i] is EditorWindow window)
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorWindow.GetWindow(type);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarningFormat("Failed to find type with name: {0}", fullname);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent LABEL_HIERARCHY = new GUIContent(string.Empty, "Show/Hide entities hierarchy window");
|
||||
public static readonly GUIContent LABEL_COMPONENTS = new GUIContent(string.Empty, "Show/Hide entities components window");
|
||||
public static readonly GUIContent LABEL_SYSTEMS = new GUIContent(string.Empty, "Show/Hide entities systems window");
|
||||
public static readonly GUIContent LABEL_ARCHETYPES = new GUIContent(string.Empty, "Show/Hide entities archetypes window");
|
||||
public static readonly GUIContent LABEL_JOURNALING = new GUIContent(string.Empty, "Show/Hide entities journaling window");
|
||||
|
||||
public static GUIContent ICON_HIERARCHY;
|
||||
public static GUIContent ICON_COMPONENTS;
|
||||
public static GUIContent ICON_SYSTEMS;
|
||||
public static GUIContent ICON_ARCHETYPES;
|
||||
public static GUIContent ICON_JOURNALING;
|
||||
|
||||
private static bool IS_INITIALIZED;
|
||||
|
||||
private const string EditorDefaultResourcesPath = "Packages/com.unity.entities/Editor Default Resources/";
|
||||
private const string EditorIconsLightDirectory = EditorDefaultResourcesPath + "icons/light";
|
||||
private const string EditorIconsDarkDirectory = EditorDefaultResourcesPath + "icons/dark";
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (IS_INITIALIZED)
|
||||
return;
|
||||
|
||||
ICON_HIERARCHY = new GUIContent(LoadIcon("EntityGroup/EntityGroup"));
|
||||
ICON_COMPONENTS = new GUIContent(LoadIcon("Component/Component"));
|
||||
ICON_SYSTEMS = new GUIContent(LoadIcon("System/System"));
|
||||
ICON_ARCHETYPES = new GUIContent(LoadIcon("Archetype/Archetype"));
|
||||
ICON_JOURNALING = new GUIContent(LoadIcon("Journaling/Journaling"));
|
||||
|
||||
IS_INITIALIZED = true;
|
||||
}
|
||||
|
||||
private static Texture2D LoadIcon(string name)
|
||||
{
|
||||
string iconsDirectory = EditorIconsLightDirectory;
|
||||
|
||||
if (EditorGUIUtility.isProSkin)
|
||||
iconsDirectory = EditorIconsDarkDirectory;
|
||||
|
||||
Object obj = AssetDatabase.LoadAssetAtPath(iconsDirectory + "/" + name + ".png", typeof(Texture2D));
|
||||
return obj != null ? (Texture2D)obj : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Samples~/SamplesToolbarEntities/ToolEntities.cs.meta
Normal file
2
Samples~/SamplesToolbarEntities/ToolEntities.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 460de731a77f02347b6ae7d35050a5f1
|
||||
Loading…
Add table
Add a link
Reference in a new issue