Created
February 27, 2019 14:55
-
-
Save ZeredaGames/e00b7c841a01b967de638cda8b310f13 to your computer and use it in GitHub Desktop.
Thit is whats up next.
This file contains 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
#region using | |
using UnityEngine; | |
#if UNITY_EDITOR | |
using UnityEditor; | |
#endif | |
//using UnityEngine.UI; | |
//using UnityEngine.SceneManagement; | |
//using System; | |
//using System.Collections; | |
using System.Collections.Generic; | |
#endregion | |
#region Script | |
namespace ZeredaGamesEngine.Core.MusicListsExamples.Example3 | |
{ | |
#region Attributes | |
//[RequireComponent (typeof())] | |
//[System.Serializable] | |
#endregion | |
public class EditorWindowTutorial : EditorWindow | |
{ | |
#region Variables | |
static List<string> LoadPaths = new List<string>(){ | |
"ZeredaGamesTutorialAssets/GeneralGameAssets/MusicAssetList", | |
"EditorWindowTextures/folder-icon", | |
"EditorWindowTextures/email-icon", | |
"EditorWindowTextures/facebook-icon", | |
"EditorWindowTextures/unity-icon", | |
"EditorWindowTextures/skype-icon", | |
"EditorWindowTextures/LogoTexture", | |
"ZeredaGamesTutorialAssets/GeneralGameAssets/WindowAsset" | |
}; | |
static Texture skypeTexture; | |
static Texture emailTexture; | |
static Texture headerLogoTexture; | |
static Texture folderIcon; | |
static Texture unityTexture; | |
static Texture facebookTexture; | |
static MusicAssetList asset = null; | |
static int selectionA, selectionB; | |
private static EditorWindowTutorial window = null; | |
///<summary> Sets Defaults in update.</summary> | |
public static bool setDefaults; | |
public bool DebugMode; | |
#endregion | |
#region Unity Methods | |
///<summary> Awake is called when the script instance is being loaded.</summary> | |
void Awake() | |
{ | |
DebugMode = GetDebugMode; | |
} | |
///<summary> Start is called just before any of the Update methods is called the first time.</summary> | |
void Start() | |
{ | |
} | |
///<summary> Update is called every frame, if the MonoBehaviour is enabled.</summary> | |
void Update() | |
{ | |
} | |
#endregion | |
[MenuItem("Window/Editor Tools/ZeredaGames/Game Making Editor Tools/Open My Custom Editor Window - Resizable", false, 0)] | |
public void Initialize() | |
{ | |
window = GetWindow; | |
// Load any and all resources now and after that this method should be complete. | |
// | |
window.DoResourceCheckAndLoad(); | |
} | |
[MenuItem("Window/Editor Tools/ZeredaGames/Game Making Editor Tools/Open My Custom Editor Window - Fixed", false, 0)] | |
public void InitializeOther() | |
{ | |
window = GetWindowWithARect(); | |
// Load any and all resources now and after that this method should be complete. | |
// | |
window.DoResourceCheckAndLoad(); | |
} | |
[MenuItem("Window/Editor Tools/ZeredaGames/Tutorials/Show Tutorial Window")] | |
static EditorWindowTutorial SelectReadme() | |
{ | |
var ids = AssetDatabase.FindAssets("EditorWindowTutorial t:EditorWindowTutorial"); | |
if (ids.Length == 1) | |
{ | |
var readmeObject = AssetDatabase.LoadMainAssetAtPath(Application.dataPath + "Resourcex/" + LoadPaths[7]); | |
Selection.objects = new UnityEngine.Object[] { readmeObject }; | |
return (EditorWindowTutorial)readmeObject; | |
} | |
else | |
{ | |
Debug.Log("Couldn't find a Custom Editor Window"); | |
return null; | |
} | |
} | |
static string StaticString="My Window"; | |
private EditorWindowTutorial GetWindowWithARect() | |
{ | |
//Set the window to spacific size | |
// | |
EditorWindow.GetWindowWithRect(typeof(EditorWindowTutorial), new Rect(100, 250, 455, 650), true, StaticString); | |
//automatically repaint whenever the scene has changed (for caution) | |
// | |
window.autoRepaintOnSceneChange = true; | |
return (EditorWindowTutorial)EditorWindow.GetWindow(typeof(EditorWindowTutorial), true, "My Custom Window (Look you can Write w.e you like here!))"); | |
} | |
void DoReCheck() | |
{ | |
if (asset == null || headerLogoTexture == null || emailTexture == null || unityTexture == null || facebookTexture == null || skypeTexture == null || folderIcon == null) | |
{ | |
asset = (MusicAssetList)Resources.Load(LoadPaths[0]); | |
folderIcon = Resources.Load<Texture>(LoadPaths[1]); | |
emailTexture = Resources.Load<Texture>(LoadPaths[2]); | |
facebookTexture = Resources.Load<Texture>(LoadPaths[3]); | |
unityTexture = Resources.Load<Texture>(LoadPaths[4]); | |
skypeTexture = Resources.Load<Texture>(LoadPaths[5]); | |
headerLogoTexture = Resources.Load<Texture>(LoadPaths[6]); | |
} | |
} | |
void DoResourceCheckAndLoad() | |
{ | |
// Let's also do a safety check for each our resources, and desplay whats happening | |
// to the console. | |
Object obj = Resources.Load(LoadPaths[0]); | |
if (Equals(obj, null)) | |
{ | |
asset = MusicAssetList.CreateNewAsset(); | |
if (DebugMode) | |
Debug.Log("Asset Crested @ " + LoadPaths[0]); | |
} | |
else { | |
asset = (MusicAssetList)Resources.Load(LoadPaths[0]); | |
if (DebugMode) | |
Debug.Log("Asset Found @ " + LoadPaths[0]); | |
} | |
// Make sure there is a folder in resources named "EditorWindowTextures" | |
// | |
// small icon image for Documentation URL Link | |
Object obj2 = Resources.Load(LoadPaths[1]); | |
if (Equals(obj2, null)) | |
{ | |
if (DebugMode) | |
Debug.Log("Asset missing @ " + LoadPaths[1]); | |
} | |
else { | |
folderIcon = Resources.Load<Texture>(LoadPaths[1]); | |
if (DebugMode) | |
Debug.Log("Asset found @ " + LoadPaths[1]); | |
} | |
// small icon image for email link | |
Object obj3 = Resources.Load(LoadPaths[2]); | |
if (Equals(obj3, null)) | |
{ | |
if (DebugMode) | |
Debug.Log("Asset missing @ " + LoadPaths[2]); | |
} | |
else { | |
emailTexture = Resources.Load<Texture>(LoadPaths[2]); | |
if (DebugMode) | |
Debug.Log("Asset found @ " + LoadPaths[2]); | |
} | |
// small icon image for skype 'Contact beauty' image | |
Object obj4 = Resources.Load(LoadPaths[3]); | |
if (Equals(obj4, null)) | |
{ | |
if (DebugMode) | |
Debug.Log("Asset missing @ " + LoadPaths[3]); | |
} | |
else { | |
skypeTexture = Resources.Load<Texture>(LoadPaths[3]); | |
if (DebugMode) | |
Debug.Log("Asset found @ " + LoadPaths[3]); | |
} | |
// small icon image for facebook 'Contact beauty' image | |
Object obj5 = Resources.Load(LoadPaths[4]); | |
if (Equals(obj5, null)) | |
{ | |
if (DebugMode) | |
Debug.Log("Asset missing @ " + LoadPaths[4]); | |
} | |
else { | |
facebookTexture = Resources.Load<Texture>(LoadPaths[4]); | |
if (DebugMode) | |
Debug.Log("Asset found @ " + LoadPaths[4]); | |
} | |
// small icon image for Unity 'Contact beauty' image | |
Object obj6 = Resources.Load(LoadPaths[5]); | |
if (Equals(obj6, null)) | |
{ | |
if (DebugMode) | |
Debug.Log("Asset missing @ " + LoadPaths[5]); | |
} | |
else { | |
unityTexture = Resources.Load<Texture>(LoadPaths[5]); | |
if (DebugMode) | |
Debug.Log("Asset found @ " + LoadPaths[5]); | |
} | |
//Top Logo Image at top of our window ->your logo | |
Object obj7 = Resources.Load(LoadPaths[6]); | |
if (Equals(obj7, null)) | |
{ | |
if (DebugMode) | |
Debug.Log("Asset missing @ " + LoadPaths[6]); | |
} | |
else { | |
headerLogoTexture = Resources.Load<Texture>(LoadPaths[6]); | |
if (DebugMode) | |
Debug.Log("Asset found @ "+ LoadPaths[6]); | |
} | |
} | |
//Here is how we display all out data on our window, and | |
//Organizes our window layout. | |
void OnGUI() | |
{ | |
DebugMode = EditorGUILayout.Toggle("DebugMode", DebugMode); | |
EditorGUILayout.BeginHorizontal("Box"); | |
GUI.color = Color.grey; | |
Header(); | |
GUI.color = Color.white; | |
EditorGUILayout.EndHorizontal(); | |
EditorGUILayout.BeginVertical(); | |
WindowBase(); | |
EditorGUILayout.EndVertical(); | |
} | |
// Makes Base below header | |
void WindowBase() | |
{ | |
EditorGUILayout.BeginHorizontal(); | |
GUI.color = Color.yellow; | |
TabButtonArea(); | |
GUI.color = Color.white; | |
EditorGUILayout.EndHorizontal(); | |
EditorGUILayout.BeginHorizontal(); | |
GUI.color = Color.grey; | |
MainViewPort(); | |
GUI.color = Color.white; | |
EditorGUILayout.EndHorizontal(); | |
} | |
//Organizes our window layout | |
void MainViewPort() | |
{ | |
EditorGUILayout.BeginVertical("Box", GUILayout.Width(position.width / 3)); | |
ButtonListViewPort(selectionA); | |
EditorGUILayout.EndVertical(); | |
EditorGUILayout.BeginVertical(GUILayout.Width(position.width - 20)); | |
ViewPortArea(selectionB); | |
EditorGUILayout.EndVertical(); | |
} | |
// Have categories if you like make it tabular at the top of your window under your header | |
void TabButtonArea() | |
{ | |
//See Below | |
} | |
//GUI that display's to the left of the ViewPortArea holding out sections list of buttons. | |
// Each button changes what display's on ViewPortArea | |
void ButtonListViewPort(int selection) | |
{ | |
//See Below | |
} | |
//GUI that display's to the right of our list and below our tabs. | |
void ViewPortArea(int selection) | |
{ | |
//See Below | |
} | |
//GUI that display's at the very to of our window. | |
void Header() | |
{ | |
//See Below | |
} | |
#region ZeredaGames Methods | |
#region Option A | |
///<summary> Can be used for starting this instance.</summary> | |
[MenuItem("Window/Editor Tools/ZeredaGames/Game Making Editor Tools/Open My Custom Editor Window Initialize A")] | |
public static void StaticInitializeA() | |
{ | |
EditorWindowTutorial window = (EditorWindowTutorial)EditorWindow.GetWindow(typeof(EditorWindowTutorial)); | |
} | |
#endregion | |
#region Option B | |
// adjust 0 to organize the list 0 is top so in this scripts set up like is, will result in B, A, C | |
[MenuItem("Window/Editor Tools/ZeredaGames/Game Making Editor Tools/Open My Custom Editor Window Initialize B", false, 0)] | |
public static void StaticInitializeB() | |
{ | |
window = GetWindow; | |
} | |
private static EditorWindowTutorial GetWindow | |
{ | |
get | |
{ | |
return (EditorWindowTutorial)EditorWindow.GetWindow(typeof(EditorWindowTutorial), true, "Editor Window Tutorial (Look you can Write w.e you like here!))"); | |
} | |
} | |
#endregion | |
#region Option C | |
[MenuItem("Window/Editor Tools/ZeredaGames/Game Making Editor Tools/Open My Custom Editor Window Initialize C", false, 2)]// adjust 0 to organize the list | |
public static void StaticInitializeC() | |
{ | |
window = GetWindowWithRect; | |
} | |
private static EditorWindowTutorial GetWindowWithRect | |
{ | |
get | |
{ | |
return (EditorWindowTutorial)EditorWindow.GetWindowWithRect(typeof(EditorWindowTutorial),new Rect(100,100,500,500), true, "Editor Window Tutorial (Look you can Write w.e you like here!))"); | |
} | |
} | |
#endregion | |
public static bool UseA = true, UseB = false, UseC = false; | |
public void Init() | |
{ | |
if (UseA) | |
StaticInitializeA(); | |
if (UseB) | |
StaticInitializeB(); | |
if (UseC) | |
StaticInitializeC(); | |
//Start writting here | |
} | |
public bool GetDebugMode | |
{ | |
get | |
{ | |
string message = PlayerPrefs.GetString("DebugMode"); | |
if (message == "true") | |
{ | |
DebugMode = true; | |
return DebugMode; | |
} | |
else { | |
DebugMode = false; | |
return DebugMode; | |
} | |
} | |
} | |
#endregion | |
} | |
} | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment