Insanely huge initial commit

This commit is contained in:
2026-02-21 16:40:15 -08:00
parent 208d626100
commit f74c547a13
33825 changed files with 5213498 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using ES3Internal;
using System.Linq;
namespace ES3Editor
{
public class AddES3Prefab : Editor
{
[MenuItem("GameObject/Easy Save 3/Enable Easy Save for Prefab(s)", false, 1001)]
[MenuItem("Assets/Easy Save 3/Enable Easy Save for Prefab(s)", false, 1001)]
public static void Enable()
{
if (Selection.gameObjects == null || Selection.gameObjects.Length == 0)
return;
foreach (var obj in Selection.gameObjects)
{
// Don't add the Component to a GameObject which already has it.
if (obj == null || (obj.GetComponent<ES3Prefab>() != null))
continue;
var go = obj;
#if UNITY_2018_3_OR_NEWER
if (PrefabUtility.GetPrefabInstanceStatus(go) != PrefabInstanceStatus.NotAPrefab)
{
go = (GameObject)PrefabUtility.GetCorrespondingObjectFromSource(go);
if (go == null)
continue;
}
#else
if(PrefabUtility.GetPrefabType(go) != PrefabType.Prefab)
{
go = (GameObject)PrefabUtility.GetPrefabParent(go);
if(go == null)
continue;
}
#endif
var es3Prefab = Undo.AddComponent<ES3Prefab>(go);
es3Prefab.GeneratePrefabReferences();
if (ES3ReferenceMgr.Current != null)
{
ES3ReferenceMgr.Current.AddPrefab(es3Prefab);
EditorUtility.SetDirty(ES3ReferenceMgr.Current);
}
}
}
[MenuItem("GameObject/Easy Save 3/Enable Easy Save for Prefab(s)", true, 1001)]
[MenuItem("Assets/Easy Save 3/Enable Easy Save for Prefab(s)", true, 1001)]
public static bool Validate()
{
return Selection.gameObjects != null && Selection.gameObjects.Length > 0;
}
}
public class RemoveES3Prefab : Editor
{
[MenuItem("GameObject/Easy Save 3/Disable Easy Save for Prefab(s)", false, 1001)]
[MenuItem("Assets/Easy Save 3/Disable Easy Save for Prefab(s)", false, 1001)]
public static void Enable()
{
if (Selection.gameObjects == null || Selection.gameObjects.Length == 0)
return;
foreach (var obj in Selection.gameObjects)
{
var es3prefab = obj.GetComponent<ES3Prefab>();
if (es3prefab != null)
Undo.DestroyObjectImmediate(es3prefab);
}
}
[MenuItem("GameObject/Easy Save 3/Disable Easy Save for Prefab(s)", true, 1001)]
[MenuItem("Assets/Easy Save 3/Disable Easy Save for Prefab(s)", true, 1001)]
public static bool Validate()
{
return Selection.gameObjects != null && Selection.gameObjects.Length > 0;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 337c3be705d1942b3bf318b5b29aa7cb
timeCreated: 1519132282
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,368 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using ES3Internal;
using UnityEngine.SceneManagement;
using UnityEditor.SceneManagement;
namespace ES3Editor
{
[System.Serializable]
public class AutoSaveWindow : SubWindow
{
public bool showAdvancedSettings = false;
public ES3AutoSaveMgr mgr = null;
private HierarchyItem[] hierarchy = null;
public HierarchyItem selected = null;
private Vector2 hierarchyScrollPosition = Vector2.zero;
private bool sceneOpen = true;
private string searchTerm = "";
public AutoSaveWindow(EditorWindow window) : base("Auto Save", window)
{
EditorSceneManager.activeSceneChangedInEditMode += ChangedActiveScene;
}
private void ChangedActiveScene(Scene current, Scene next)
{
mgr = null;
Init();
}
public override void OnGUI()
{
Init();
if(mgr == null)
{
EditorGUILayout.Space();
if (GUILayout.Button("Enable Auto Save for this scene"))
mgr = ES3Postprocessor.AddManagerToScene().GetComponent<ES3AutoSaveMgr>();
else
return;
}
var style = EditorStyle.Get;
using (var changeCheck = new EditorGUI.ChangeCheckScope())
{
using (var vertical = new EditorGUILayout.VerticalScope(style.areaPadded))
{
//GUILayout.Label("Settings for current scene", style.heading);
mgr.saveEvent = (ES3AutoSaveMgr.SaveEvent)EditorGUILayout.EnumPopup("Save Event", mgr.saveEvent);
mgr.loadEvent = (ES3AutoSaveMgr.LoadEvent)EditorGUILayout.EnumPopup("Load Event", mgr.loadEvent);
EditorGUILayout.Space();
showAdvancedSettings = EditorGUILayout.Foldout(showAdvancedSettings, "Show Advanced Settings");
if (showAdvancedSettings)
{
EditorGUI.indentLevel++;
mgr.key = EditorGUILayout.TextField("Key", mgr.key);
ES3SettingsEditor.Draw(mgr.settings);
EditorGUI.indentLevel--;
}
}
// Display the menu.
using (var horizontal = new EditorGUILayout.HorizontalScope())
{
if (GUILayout.Button("Scene", sceneOpen ? style.menuButtonSelected : style.menuButton))
{
sceneOpen = true;
OnFocus();
}
if (GUILayout.Button("Prefabs", sceneOpen ? style.menuButton : style.menuButtonSelected))
{
sceneOpen = false;
OnFocus();
}
}
//EditorGUILayout.HelpBox("Select the Components you want to be saved.\nTo maximise performance, only select the Components with variables which need persisting.", MessageType.None, true);
if (hierarchy == null || hierarchy.Length == 0)
{
EditorGUILayout.LabelField("Right-click a prefab and select 'Easy Save 3 > Enable Easy Save for Scene' to enable Auto Save for it.\n\nYour scene will also need to reference this prefab for it to be recognised.", style.area);
return;
}
using (var scrollView = new EditorGUILayout.ScrollViewScope(hierarchyScrollPosition, style.areaPadded))
{
hierarchyScrollPosition = scrollView.scrollPosition;
using (new EditorGUILayout.HorizontalScope(GUILayout.Width(200)))
{
var searchTextFieldSkin = GUI.skin.FindStyle("ToolbarSearchTextField");
if (searchTextFieldSkin == null)
searchTextFieldSkin = GUI.skin.FindStyle("ToolbarSeachTextField");
var searchButtonSkin = GUI.skin.FindStyle("ToolbarSearchCancelButton");
if (searchButtonSkin == null)
searchButtonSkin = GUI.skin.FindStyle("ToolbarSeachCancelButton");
searchTerm = GUILayout.TextField(searchTerm, searchTextFieldSkin);
if (GUILayout.Button("", searchButtonSkin))
{
// Remove focus if cleared
searchTerm = "";
GUI.FocusControl(null);
}
}
EditorGUILayout.Space();
EditorGUILayout.Space();
foreach (var go in hierarchy)
if (go != null)
go.DrawHierarchy(searchTerm.ToLowerInvariant());
}
if (changeCheck.changed)
EditorUtility.SetDirty(mgr);
}
}
public void Init()
{
if (mgr == null)
foreach (var thisMgr in Resources.FindObjectsOfTypeAll<ES3AutoSaveMgr>())
if (thisMgr != null && thisMgr.gameObject.scene == SceneManager.GetActiveScene())
mgr = thisMgr;
if (hierarchy == null)
OnFocus();
}
public override void OnFocus()
{
GameObject[] parentObjects;
if (sceneOpen)
parentObjects = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
else // Prefabs
{
var prefabs = ES3ReferenceMgr.Current.prefabs;
parentObjects = new GameObject[prefabs.Count];
for (int i = 0; i < prefabs.Count; i++)
if(prefabs[i] != null)
parentObjects[i] = prefabs[i].gameObject;
}
hierarchy = new HierarchyItem[parentObjects.Length];
for (int i = 0; i < parentObjects.Length; i++)
if(parentObjects[i] != null)
hierarchy[i] = new HierarchyItem(parentObjects[i].transform, null, this);
}
public class HierarchyItem
{
private ES3AutoSave autoSave;
private Transform t;
private Component[] components = null;
// Immediate children of this GameObject
private HierarchyItem[] children = new HierarchyItem[0];
private bool showComponents = false;
//private AutoSaveWindow window;
public HierarchyItem(Transform t, HierarchyItem parent, AutoSaveWindow window)
{
this.autoSave = t.GetComponent<ES3AutoSave>();
this.t = t;
this.components = t.GetComponents<Component>();
children = new HierarchyItem[t.childCount];
for (int i = 0; i < t.childCount; i++)
children[i] = new HierarchyItem(t.GetChild(i), this, window);
//this.window = window;
}
public void MergeDown(ES3AutoSave autoSave)
{
if (this.autoSave != autoSave)
{
if (this.autoSave != null)
{
autoSave.componentsToSave.AddRange(autoSave.componentsToSave);
Object.DestroyImmediate(this.autoSave);
}
this.autoSave = autoSave;
}
foreach (var child in children)
MergeDown(autoSave);
}
public void DrawHierarchy(string searchTerm)
{
bool containsSearchTerm = false;
if (t != null)
{
// Filter by tag if it's prefixed by "tag:"
if (searchTerm.StartsWith("tag:") && t.tag.ToLowerInvariant().Contains(searchTerm.Remove(0,4)))
containsSearchTerm = true;
// Else filter by name
else
containsSearchTerm = t.name.ToLowerInvariant().Contains(searchTerm);
if (containsSearchTerm)
{
GUIContent saveIcon;
EditorGUIUtility.SetIconSize(new Vector2(16, 16));
if (HasSelectedComponentsOrFields())
saveIcon = new GUIContent(t.name, EditorStyle.Get.saveIconSelected, "There are Components on this GameObject which will be saved.");
else
saveIcon = new GUIContent(t.name, EditorStyle.Get.saveIconUnselected, "No Components on this GameObject will be saved");
GUIStyle style = GUI.skin.GetStyle("Foldout");
if (Selection.activeTransform == t)
{
style = new GUIStyle(style);
style.fontStyle = FontStyle.Bold;
}
var open = EditorGUILayout.Foldout(showComponents, saveIcon, style);
if (open)
{
// Ping the GameObject if this was previously closed
if (showComponents != open)
EditorGUIUtility.PingObject(t.gameObject);
DrawComponents();
}
showComponents = open;
EditorGUI.indentLevel += 1;
}
}
// Draw children
if (children != null)
foreach (var child in children)
if (child != null)
child.DrawHierarchy(searchTerm);
if (containsSearchTerm)
EditorGUI.indentLevel -= 1;
}
public void DrawComponents()
{
EditorGUI.indentLevel += 3;
using (var scope = new EditorGUILayout.VerticalScope())
{
bool toggle;
toggle = EditorGUILayout.ToggleLeft("active", autoSave != null ? autoSave.saveActive : false);
if ((autoSave = (toggle && autoSave == null) ? t.gameObject.AddComponent<ES3AutoSave>() : autoSave) != null)
ApplyBool("saveActive", toggle);
toggle = EditorGUILayout.ToggleLeft("hideFlags", autoSave != null ? autoSave.saveHideFlags : false);
if ((autoSave = (toggle && autoSave == null) ? t.gameObject.AddComponent<ES3AutoSave>() : autoSave) != null)
ApplyBool("saveHideFlags", toggle);
toggle = EditorGUILayout.ToggleLeft("layer", autoSave != null ? autoSave.saveLayer : false);
if ((autoSave = (toggle && autoSave == null) ? t.gameObject.AddComponent<ES3AutoSave>() : autoSave) != null)
ApplyBool("saveLayer", toggle);
toggle = EditorGUILayout.ToggleLeft("name", autoSave != null ? autoSave.saveName : false);
if ((autoSave = (toggle && autoSave == null) ? t.gameObject.AddComponent<ES3AutoSave>() : autoSave) != null)
ApplyBool("saveName", toggle);
toggle = EditorGUILayout.ToggleLeft("tag", autoSave != null ? autoSave.saveTag : false);
if ((autoSave = (toggle && autoSave == null) ? t.gameObject.AddComponent<ES3AutoSave>() : autoSave) != null)
ApplyBool("saveTag", toggle);
foreach (var component in components)
{
if (component == null)
continue;
using (var horizontalScope = new EditorGUILayout.HorizontalScope())
{
bool saveComponent = false;
if (autoSave != null)
saveComponent = autoSave.componentsToSave.Contains(component);
var newValue = EditorGUILayout.ToggleLeft(EditorGUIUtility.ObjectContent(component, component.GetType()), saveComponent);
// If the checkbox has changed, we want to save or not save a Component
if (newValue != saveComponent)
{
if (autoSave == null)
{
autoSave = Undo.AddComponent<ES3AutoSave>(t.gameObject);
var so = new SerializedObject(autoSave);
so.FindProperty("saveChildren").boolValue = false;
so.ApplyModifiedProperties();
}
// If we've unchecked the box, remove the Component from the array.
if (newValue == false)
{
var so = new SerializedObject(autoSave);
var prop = so.FindProperty("componentsToSave");
var index = autoSave.componentsToSave.IndexOf(component);
prop.DeleteArrayElementAtIndex(index);
so.ApplyModifiedProperties();
}
// Else, add it to the array.
else
{
var so = new SerializedObject(autoSave);
var prop = so.FindProperty("componentsToSave");
prop.arraySize++;
prop.GetArrayElementAtIndex(prop.arraySize - 1).objectReferenceValue = component;
so.ApplyModifiedProperties();
}
}
if (GUILayout.Button(EditorGUIUtility.IconContent("_Popup"), new GUIStyle("Label")))
ES3Window.InitAndShowTypes(component.GetType());
}
}
}
/*if(autoSave != null && isDirty)
{
EditorUtility.SetDirty(autoSave);
if (PrefabUtility.IsPartOfPrefabInstance(autoSave))
PrefabUtility.RecordPrefabInstancePropertyModifications(autoSave.gameObject);
}*/
if (autoSave != null && (autoSave.componentsToSave == null || autoSave.componentsToSave.Count == 0) && !autoSave.saveActive && !autoSave.saveChildren && !autoSave.saveHideFlags && !autoSave.saveLayer && !autoSave.saveName && !autoSave.saveTag)
{
Undo.DestroyObjectImmediate(autoSave);
autoSave = null;
}
EditorGUI.indentLevel -= 3;
}
public void ApplyBool(string propertyName, bool value)
{
var so = new SerializedObject(autoSave);
so.FindProperty(propertyName).boolValue = value;
so.ApplyModifiedProperties();
}
public bool HasSelectedComponentsOrFields()
{
if (autoSave == null)
return false;
foreach (var component in components)
if (component != null && autoSave.componentsToSave.Contains(component))
return true;
if (autoSave.saveActive || autoSave.saveHideFlags || autoSave.saveLayer || autoSave.saveName || autoSave.saveTag)
return true;
return false;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6065cc5492e9f49728674de9a0c1fe84
timeCreated: 1519132286
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
using UnityEditor;
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace ES3Internal
{
[CustomEditor(typeof(ES3AutoSave))]
public class ES3AutoSaveEditor : Editor
{
public override void OnInspectorGUI()
{
if (target == null)
return;
if (GUILayout.Button("Manage Auto Save Settings"))
ES3Editor.ES3Window.InitAndShowAutoSave();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 54ded3aeb20a94008a877da330bfc45f
timeCreated: 1519132285
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using UnityEditor;
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace ES3Internal
{
[CustomEditor(typeof(ES3AutoSaveMgr))]
public class ES3AutoSaveMgrEditor : Editor
{
public override void OnInspectorGUI()
{
EditorGUILayout.HelpBox("This manages the saving and loading of GameObjects which have the Auto Save component attached to them.\n\nIf there are no Auto Save components in your scene, this component will do nothing.", MessageType.Info);
if(GUILayout.Button("Settings..."))
ES3Editor.ES3Window.InitAndShowAutoSave();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f440317f3fd444daf83c27a3381af17c
timeCreated: 1519132300
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,54 @@
using System;
using UnityEngine;
namespace ES3Types
{
[UnityEngine.Scripting.Preserve]
[ES3PropertiesAttribute([propertyNames])]
public class ES3UserType_[es3TypeSuffix] : ES3ObjectType
{
public static ES3Type Instance = null;
public ES3UserType_[es3TypeSuffix]() : base(typeof([fullType])){ Instance = this; priority = 1; }
protected override void WriteObject(object obj, ES3Writer writer)
{
var instance = ([fullType])obj;
[writes]
}
protected override void ReadObject<T>(ES3Reader reader, object obj)
{
var instance = ([fullType])obj;
foreach(string propertyName in reader.Properties)
{
switch(propertyName)
{
[reads]
default:
reader.Skip();
break;
}
}
}
protected override object ReadObject<T>(ES3Reader reader)
{
var instance = new [fullType]();
ReadObject<T>(reader, instance);
return instance;
}
}
public class ES3UserType_[es3TypeSuffix]Array : ES3ArrayType
{
public static ES3Type Instance;
public ES3UserType_[es3TypeSuffix]Array() : base(typeof([fullType][]), ES3UserType_[es3TypeSuffix].Instance)
{
Instance = this;
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cc3cada215f0d417a8fa879651f22f84
timeCreated: 1483698819
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,47 @@
using System;
using UnityEngine;
namespace ES3Types
{
[UnityEngine.Scripting.Preserve]
[ES3PropertiesAttribute([propertyNames])]
public class ES3UserType_[es3TypeSuffix] : ES3ComponentType
{
public static ES3Type Instance = null;
public ES3UserType_[es3TypeSuffix]() : base(typeof([fullType])){ Instance = this; priority = 1;}
protected override void WriteComponent(object obj, ES3Writer writer)
{
var instance = ([fullType])obj;
[writes]
}
protected override void ReadComponent<T>(ES3Reader reader, object obj)
{
var instance = ([fullType])obj;
foreach(string propertyName in reader.Properties)
{
switch(propertyName)
{
[reads]
default:
reader.Skip();
break;
}
}
}
}
public class ES3UserType_[es3TypeSuffix]Array : ES3ArrayType
{
public static ES3Type Instance;
public ES3UserType_[es3TypeSuffix]Array() : base(typeof([fullType][]), ES3UserType_[es3TypeSuffix].Instance)
{
Instance = this;
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b74f7ff5e731846249f9e22ab7afedfb
timeCreated: 1483698819
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,84 @@
using System.Collections;
using UnityEngine;
using UnityEditor;
namespace ES3Editor
{
public class EditorStyle
{
private static EditorStyle style = null;
public GUIStyle area;
public GUIStyle areaPadded;
public GUIStyle menuButton;
public GUIStyle menuButtonSelected;
public GUIStyle smallSquareButton;
public GUIStyle heading;
public GUIStyle subheading;
public GUIStyle subheading2;
public GUIStyle boldLabelNoStretch;
public GUIStyle link;
public GUIStyle toggle;
public Texture2D saveIconSelected;
public Texture2D saveIconUnselected;
public static EditorStyle Get { get{ if(style == null) style = new EditorStyle(); return style; } }
public EditorStyle()
{
// An area with padding.
area = new GUIStyle();
area.padding = new RectOffset(10, 10, 10, 10);
area.wordWrap = true;
// An area with more padding.
areaPadded = new GUIStyle();
areaPadded.padding = new RectOffset(20, 20, 20, 20);
areaPadded.wordWrap = true;
// Unselected menu button.
menuButton = new GUIStyle(EditorStyles.toolbarButton);
menuButton.fontStyle = FontStyle.Normal;
menuButton.fontSize = 14;
menuButton.fixedHeight = 24;
// Selected menu button.
menuButtonSelected = new GUIStyle(menuButton);
menuButtonSelected.fontStyle = FontStyle.Bold;
// Main Headings
heading = new GUIStyle(EditorStyles.label);
heading.fontStyle = FontStyle.Bold;
heading.fontSize = 24;
subheading = new GUIStyle(heading);
subheading.fontSize = 18;
subheading2 = new GUIStyle(heading);
subheading2.fontSize = 14;
boldLabelNoStretch = new GUIStyle(EditorStyles.label);
boldLabelNoStretch.stretchWidth = false;
boldLabelNoStretch.fontStyle = FontStyle.Bold;
link = new GUIStyle();
link.fontSize = 16;
if(EditorGUIUtility.isProSkin)
link.normal.textColor = new Color (0.262f, 0.670f, 0.788f);
else
link.normal.textColor = new Color (0.129f, 0.129f, 0.8f);
toggle = new GUIStyle(EditorStyles.toggle);
toggle.stretchWidth = false;
saveIconSelected = AssetDatabase.LoadAssetAtPath<Texture2D>(ES3Settings.PathToEasySaveFolder() + "Editor/es3Logo16x16.png");
saveIconUnselected = AssetDatabase.LoadAssetAtPath<Texture2D>(ES3Settings.PathToEasySaveFolder() + "Editor/es3Logo16x16-bw.png");
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f556addc6753344019137cbc45d2c4ff
timeCreated: 1519132301
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Linq;
using ES3Internal;
public class ES3EditorUtility : Editor
{
public static void DisplayLink(string label, string url)
{
var style = ES3Editor.EditorStyle.Get;
if(GUILayout.Button(label, style.link))
Application.OpenURL(url);
var buttonRect = GUILayoutUtility.GetLastRect();
buttonRect.width = style.link.CalcSize(new GUIContent(label)).x;
EditorGUIUtility.AddCursorRect(buttonRect, MouseCursor.Link);
}
public static bool IsPrefabInAssets(UnityEngine.Object obj)
{
#if UNITY_2018_3_OR_NEWER
return PrefabUtility.IsPartOfPrefabAsset(obj);
#else
return (PrefabUtility.GetPrefabType(obj) == PrefabType.Prefab);
#endif
}
/*
* Gets all children and components from a GameObject or GameObjects.
* We create our own method for this because EditorUtility.CollectDeepHierarchy isn't thread safe in the Editor.
*/
public static IEnumerable<UnityEngine.Object> CollectDeepHierarchy(IEnumerable<GameObject> gos)
{
var deepHierarchy = new HashSet<UnityEngine.Object>();
foreach (var go in gos)
{
deepHierarchy.Add(go);
deepHierarchy.UnionWith(go.GetComponents<Component>());
foreach (Transform t in go.transform)
deepHierarchy.UnionWith( CollectDeepHierarchy( new GameObject[] { t.gameObject } ) );
}
return deepHierarchy;
}
[MenuItem("Tools/Easy Save 3/Getting Started...", false, 0)]
public static void DisplayGettingStarted()
{
Application.OpenURL("https://docs.moodkie.com/easy-save-3/getting-started/");
}
[MenuItem("Tools/Easy Save 3/Manual...", false, 0)]
public static void DisplayManual()
{
Application.OpenURL("https://docs.moodkie.com/product/easy-save-3/");
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 501719249e8124990973182985feaeb8
timeCreated: 1519132285
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,46 @@
using UnityEditor;
using UnityEngine;
namespace ES3Internal
{
[CustomEditor(typeof(ES3GameObject))]
public class ES3GameObjectEditor : Editor
{
public override void OnInspectorGUI()
{
if (target == null)
return;
var es3Go = (ES3GameObject)target;
EditorGUILayout.HelpBox("This Component allows you to choose which Components are saved when this GameObject is saved using code.", MessageType.Info);
if (es3Go.GetComponent<ES3AutoSave>() != null)
{
EditorGUILayout.HelpBox("This Component cannot be used on GameObjects which are already managed by Auto Save.", MessageType.Error);
return;
}
foreach (var component in es3Go.GetComponents<Component>())
{
var markedToBeSaved = es3Go.components.Contains(component);
var newMarkedToBeSaved = EditorGUILayout.Toggle(component.GetType().Name, markedToBeSaved);
if(markedToBeSaved && !newMarkedToBeSaved)
{
Undo.RecordObject(es3Go, "Marked Component to save");
es3Go.components.Remove(component);
}
if (!markedToBeSaved && newMarkedToBeSaved)
{
Undo.RecordObject(es3Go, "Unmarked Component to save");
es3Go.components.Add(component);
}
}
if (es3Go.components.RemoveAll(t => t == null) > 0)
Undo.RecordObject(es3Go, "Removed null Component from ES3GameObject");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b7d54ef20554e354eb3c0d40d2a6debe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,91 @@
#if !ES3GLOBAL_DISABLED
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using System;
using System.Collections;
using System.Collections.Generic;
namespace ES3Internal
{
[CustomEditor(typeof(ES3Internal.ES3GlobalReferences))]
[System.Serializable]
public class ES3GlobalReferencesEditor : Editor
{
private bool isDraggingOver = false;
private bool openReferences = false;
private ES3Internal.ES3GlobalReferences _globalRefs = null;
private ES3Internal.ES3GlobalReferences globalRefs
{
get
{
if (_globalRefs == null)
_globalRefs = (ES3Internal.ES3GlobalReferences)serializedObject.targetObject;
return _globalRefs;
}
}
public override void OnInspectorGUI()
{
EditorGUILayout.HelpBox("This stores references to objects in Assets, allowing them to be referenced with the same ID between scenes.", MessageType.Info);
if (EditorGUILayout.Foldout(openReferences, "References") != openReferences)
{
openReferences = !openReferences;
if (openReferences == true)
openReferences = EditorUtility.DisplayDialog("Are you sure?", "Opening this list will display every reference in the manager, which for larger projects can cause the Editor to freeze\n\nIt is strongly recommended that you save your project before continuing.", "Open References", "Cancel");
}
// Make foldout drag-and-drop enabled for objects.
if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
{
Event evt = Event.current;
switch (evt.type)
{
case EventType.DragUpdated:
case EventType.DragPerform:
isDraggingOver = true;
break;
case EventType.DragExited:
isDraggingOver = false;
break;
}
if (isDraggingOver)
{
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
if (evt.type == EventType.DragPerform)
{
DragAndDrop.AcceptDrag();
Undo.RecordObject(globalRefs, "Add References to Easy Save 3 Reference List");
foreach (UnityEngine.Object obj in DragAndDrop.objectReferences)
globalRefs.GetOrAdd(obj);
// Return now because otherwise we'll change the GUI during an event which doesn't allow it.
return;
}
}
}
if (openReferences)
{
EditorGUI.indentLevel++;
foreach (var kvp in globalRefs.refId)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.ObjectField(kvp.Key, typeof(UnityEngine.Object), true);
EditorGUILayout.LongField(kvp.Value);
EditorGUILayout.EndHorizontal();
}
EditorGUI.indentLevel--;
}
}
}
}
#endif

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 286fb0c3863779e4d96bc682edb324ce
timeCreated: 1519132283
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using System;
using System.Collections;
[CustomEditor(typeof(ES3InspectorInfo))]
public class ES3InspectorInfoEditor : Editor
{
public override void OnInspectorGUI()
{
EditorGUILayout.HelpBox(((ES3InspectorInfo)target).message, MessageType.Info);
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b344d685b614044aebf5285c5f59f52d
timeCreated: 1519132294
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,803 @@
#if PLAYMAKER_1_8_OR_NEWER
using UnityEngine;
using UnityEditor;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using HutongGames.PlayMakerEditor;
using System.Text.RegularExpressions;
namespace ES3PlayMaker
{
#region Base Actions
public abstract class BaseEditor : CustomActionEditor
{
bool showErrorHandling = false;
public abstract void DrawGUI();
public override bool OnGUI()
{
DrawGUI();
EditorGUILayout.Separator();
showErrorHandling = EditorGUILayout.Foldout(showErrorHandling, "Error Handling");
if (showErrorHandling)
{
EditorGUI.indentLevel++;
EditField("errorEvent");
EditField("errorMessage");
EditorGUI.indentLevel--;
}
return GUI.changed;
}
// Displays the FsmVar field without the unnecessary Type field.
protected void FsmVarField(string fieldName)
{
if (target == null || target.State == null)
return;
var fsmVar = (FsmVar)ES3Internal.ES3Reflection.GetField(target.GetType(), fieldName).GetValue(target);
if (fsmVar == null)
{
fsmVar = new FsmVar();
ES3Internal.ES3Reflection.GetField(target.GetType(), fieldName).SetValue(target, fsmVar);
}
EditorGUILayout.BeginHorizontal();
var label = Regex.Replace(fieldName, @"\p{Lu}", m => " " + m.Value.ToLowerInvariant());
EditorGUILayout.PrefixLabel(char.ToUpperInvariant(label[0]) + label.Substring(1));
var localVariables = target.Fsm.Variables.GetAllNamedVariablesSorted();
var globalVariables = FsmVariables.GlobalVariables.GetAllNamedVariablesSorted();
var variableNames = new string[localVariables.Length + globalVariables.Length];
int selected = -1;
for(int i=0; i<variableNames.Length; i++)
{
var variable = i >= localVariables.Length ? globalVariables[i - localVariables.Length] : localVariables[i];
variableNames[i] = i >= localVariables.Length ? "Globals/"+variable.Name : variable.Name;
if (fsmVar.NamedVar == variable)
selected = i;
}
var newSelected = EditorGUILayout.Popup(selected, variableNames);
EditorGUILayout.EndHorizontal();
if (newSelected == -1)
return;
if (selected != newSelected)
{
if (newSelected >= localVariables.Length)
fsmVar.NamedVar = globalVariables[newSelected - localVariables.Length];
else
fsmVar.NamedVar = localVariables[newSelected];
}
}
}
public abstract class SettingsEditor : BaseEditor
{
public override bool OnGUI()
{
base.OnGUI();
return DrawSettingsEditor();
}
public bool DrawSettingsEditor()
{
var action = target as ES3PlayMaker.SettingsAction;
if (action == null)
return false;
action.overrideDefaultSettings.Value = EditorGUILayout.ToggleLeft("Override Default Settings", action.overrideDefaultSettings.Value);
if (action.overrideDefaultSettings.Value)
{
EditorGUI.indentLevel++;
EditField("path");
EditField("location");
EditField("encryptionType");
EditField("encryptionPassword");
EditField("compressionType");
EditField("directory");
EditField("format");
EditField("bufferSize");
EditorGUI.indentLevel--;
EditorGUILayout.Space();
}
return GUI.changed;
}
}
public abstract class KeyValueSettingsEditor : SettingsEditor
{
public override bool OnGUI()
{
EditField("key");
EditField("value");
base.OnGUI();
return GUI.changed;
}
public override void DrawGUI(){}
}
public abstract class ES3FileActionEditor : BaseEditor
{
public override bool OnGUI()
{
EditField("fsmES3File");
base.OnGUI();
var action = target as ES3PlayMaker.ES3FileAction;
if (action == null)
return false;
return GUI.changed;
}
}
#endregion
#if !PLAYMAKER_1_9_OR_NEWER
#region Save Actions
/*[CustomActionEditor(typeof(ES3PlayMaker.Save))]
public class SaveEditor : KeyValueSettingsEditor{}*/
/*[CustomActionEditor(typeof(ES3PlayMaker.SaveMultiple))]
public class SaveMultipleEditor : SettingsEditor
{
public override bool OnGUI()
{
return base.OnGUI();
}
public override void DrawGUI()
{
DrawDefaultInspector();
}
}*/
[CustomActionEditor(typeof(ES3PlayMaker.SaveAll))]
public class SaveAllEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("key");
EditField("saveFsmVariables");
EditField("saveGlobalVariables");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.SaveRaw))]
public class SaveRawEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("str");
EditField("useBase64Encoding");
EditField("appendNewline");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.AppendRaw))]
public class AppendRawEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("str");
EditField("useBase64Encoding");
EditField("appendNewline");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.SaveImage))]
public class SaveImageEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("imagePath");
EditField("texture2D");
EditField("quality");
}
}
#endregion
#region Load Actions
[CustomActionEditor(typeof(ES3PlayMaker.Load))]
public class LoadEditor : KeyValueSettingsEditor
{
public override void DrawGUI()
{
EditorGUILayout.Space();
EditField("defaultValue");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.LoadInto))]
public class LoadIntoEditor : KeyValueSettingsEditor{}
[CustomActionEditor(typeof(ES3PlayMaker.LoadAll))]
public class LoadAllEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("key");
EditField("loadFsmVariables");
EditField("loadGlobalVariables");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.LoadAudio))]
public class LoadAudioEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("audioFilePath");
EditField("audioClip");
#if UNITY_2018_3_OR_NEWER
EditField("audioType");
#endif
}
}
[CustomActionEditor(typeof(ES3PlayMaker.LoadImage))]
public class LoadImageEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("imagePath");
EditField("texture2D");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.LoadRawString))]
public class LoadRawStringEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("str");
EditField("useBase64Encoding");
}
}
#endregion
#region Exists Actions
[CustomActionEditor(typeof(ES3PlayMaker.KeyExists))]
public class KeyExistsEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("key");
EditField("exists");
EditorGUILayout.Separator();
EditField("existsEvent");
EditField("doesNotExistEvent");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.FileExists))]
public class FileExistsEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("filePath");
EditField("exists");
EditorGUILayout.Separator();
EditField("existsEvent");
EditField("doesNotExistEvent");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.DirectoryExists))]
public class DirectoryExistsEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("directoryPath");
EditField("exists");
EditorGUILayout.Separator();
EditField("existsEvent");
EditField("doesNotExistEvent");
}
}
#endregion
#region Delete Actions
[CustomActionEditor(typeof(ES3PlayMaker.DeleteKey))]
public class DeleteKeyEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("key");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.DeleteFile))]
public class DeleteFileEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("filePath");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.DeleteDirectory))]
public class DeleteDirectoryEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("directoryPath");
}
}
#endregion
#region Backup Actions
[CustomActionEditor(typeof(ES3PlayMaker.CreateBackup))]
public class CreateBackupEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("filePath");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.RestoreBackup))]
public class RestoreBackupEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("filePath");
EditField("backupWasRestored");
}
}
#endregion
#region Key, File and Directory methods
[CustomActionEditor(typeof(ES3PlayMaker.RenameFile))]
public class RenameFileEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("oldFilePath");
EditField("newFilePath");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.CopyFile))]
public class CopyFileEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("oldFilePath");
EditField("newFilePath");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.CopyDirectory))]
public class CopyDirectoryEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("oldDirectoryPath");
EditField("newDirectoryPath");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.GetKeys))]
public class GetKeysEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("filePath");
EditField("keys");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.GetKeyCount))]
public class GetKeyCountEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("filePath");
EditField("keyCount");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.GetFiles))]
public class GetFilesEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("directoryPath");
EditField("files");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.GetDirectories))]
public class GetDirectoriesEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("directoryPath");
EditField("directories");
}
}
#endregion
#region ES3File Actions
[CustomActionEditor(typeof(ES3PlayMaker.ES3FileCreate))]
public class ES3FileCreateEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("fsmES3File");
EditField("filePath");
EditField("syncWithFile");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3FileSync))]
public class ES3FileSyncEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("fsmES3File");
}
}
/*[CustomActionEditor(typeof(ES3PlayMaker.ES3FileSave))]
public class ES3FileSaveEditor : SaveEditor
{
public override void DrawGUI()
{
EditField("fsmES3File");
base.DrawGUI();
}
}*/
[CustomActionEditor(typeof(ES3PlayMaker.ES3FileLoad))]
public class ES3FileLoadEditor : LoadEditor
{
public override void DrawGUI()
{
EditField("fsmES3File");
base.DrawGUI();
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3FileLoadInto))]
public class ES3FileLoadIntoEditor : LoadIntoEditor
{
public override void DrawGUI()
{
base.DrawGUI();
EditField("fsmES3File");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3FileDeleteKey))]
public class ES3FileDeleteKeyEditor : DeleteKeyEditor
{
public override void DrawGUI()
{
base.DrawGUI();
EditField("fsmES3File");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3FileKeyExists))]
public class ES3FileKeyExistsEditor : KeyExistsEditor
{
public override void DrawGUI()
{
EditField("fsmES3File");
base.DrawGUI();
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3FileGetKeys))]
public class ES3FileGetKeysEditor : ES3FileActionEditor
{
public override void DrawGUI()
{
EditField("keys");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3FileClear))]
public class ES3FileClearEditor : BaseEditor
{
public override void DrawGUI()
{
EditField("fsmES3File");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3FileSize))]
public class ES3FileSizeEditor : BaseEditor
{
public override void DrawGUI()
{
EditField("size");
EditField("fsmES3File");
}
}
#endregion
#region ES3Cloud Actions
#if !DISABLE_WEB
public abstract class ES3CloudEditor : SettingsEditor
{
protected abstract void DrawChildGUI();
public override void DrawGUI()
{
EditField("url");
EditField("apiKey");
EditorGUILayout.Space();
DrawChildGUI();
EditorGUILayout.Space();
EditField("errorCode");
}
}
public abstract class ES3CloudUserEditor : ES3CloudEditor
{
public bool showUser = false;
protected override void DrawChildGUI()
{
if((showUser = EditorGUILayout.Foldout(showUser, "User (optional)")))
{
EditorGUI.indentLevel++;
EditField("user");
EditField("password");
EditorGUI.indentLevel--;
}
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3CloudSync))]
public class ES3CloudSyncEditor : ES3CloudUserEditor
{
protected override void DrawChildGUI()
{
EditField("path");
base.DrawChildGUI();
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3CloudDownloadFile))]
public class ES3CloudDownloadFileEditor : ES3CloudUserEditor
{
protected override void DrawChildGUI()
{
EditField("path");
base.DrawChildGUI();
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3CloudDownloadES3File))]
public class ES3CloudDownloadES3FileEditor : BaseEditor
{
public bool showUser = false;
public override void DrawGUI()
{
EditField("fsmES3File");
EditField("url");
EditField("apiKey");
EditField("errorCode");
if ((showUser = EditorGUILayout.Foldout(showUser, "User (optional)")))
{
EditorGUI.indentLevel++;
EditField("user");
EditField("password");
EditorGUI.indentLevel--;
}
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3CloudUploadFile))]
public class ES3CloudUploadFileEditor : ES3CloudUserEditor
{
protected override void DrawChildGUI()
{
EditField("path");
base.DrawChildGUI();
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3CloudUploadES3File))]
public class ES3CloudUploadES3FileEditor : BaseEditor
{
public bool showUser = false;
public override void DrawGUI()
{
EditField("fsmES3File");
EditField("url");
EditField("apiKey");
EditField("errorCode");
if((showUser = EditorGUILayout.Foldout(showUser, "User (optional)")))
{
EditorGUI.indentLevel++;
EditField("user");
EditField("password");
EditorGUI.indentLevel--;
}
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3CloudDeleteFile))]
public class ES3CloudDeleteFileEditor : ES3CloudUserEditor
{
protected override void DrawChildGUI()
{
EditField("path");
base.DrawChildGUI();
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3CloudRenameFile))]
public class ES3CloudRenameFileEditor : ES3CloudUserEditor
{
protected override void DrawChildGUI()
{
EditField("path");
EditField("newFilename");
base.DrawChildGUI();
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3CloudDownloadFilenames))]
public class ES3CloudDownloadFilenamesEditor : ES3CloudUserEditor
{
protected override void DrawChildGUI()
{
EditField("filenames");
EditField("searchPattern");
base.DrawChildGUI();
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3CloudSearchFilenames))]
public class ES3CloudSearchFilenamesEditor : ES3CloudUserEditor
{
protected override void DrawChildGUI()
{
EditField("filenames");
EditField("searchPattern");
base.DrawChildGUI();
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3CloudDownloadTimestamp))]
public class ES3CloudDownloadTimestampEditor : ES3CloudUserEditor
{
protected override void DrawChildGUI()
{
EditField("path");
EditField("timestamp");
base.DrawChildGUI();
}
}
#endif
#endregion
#region ES3SpreadsheetActions
[CustomActionEditor(typeof(ES3PlayMaker.ES3SpreadsheetCreate))]
public class ES3SpreadsheetCreateEditor : BaseEditor
{
public override void DrawGUI()
{
EditField("fsmES3Spreadsheet");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3SpreadsheetSetCell))]
public class ES3SpreadsheetSetCellEditor : BaseEditor
{
public override void DrawGUI()
{
EditField("fsmES3Spreadsheet");
EditField("col");
EditField("row");
EditField("value");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3SpreadsheetGetCell))]
public class ES3SpreadsheetGetCellEditor : BaseEditor
{
public override void DrawGUI()
{
EditField("fsmES3Spreadsheet");
EditField("col");
EditField("row");
EditField("value");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3SpreadsheetLoad))]
public class ES3SpreadsheetLoadEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("fsmES3Spreadsheet");
EditField("filePath");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.ES3SpreadsheetSave))]
public class ES3SpreadsheetSaveEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("fsmES3Spreadsheet");
EditField("filePath");
EditField("append");
}
}
#endregion
#region Caching
[CustomActionEditor(typeof(ES3PlayMaker.CacheFile))]
public class CacheFileEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("filePath");
}
}
[CustomActionEditor(typeof(ES3PlayMaker.StoreCachedFile))]
public class StoreCachedFileEditor : SettingsEditor
{
public override void DrawGUI()
{
EditField("filePath");
}
}
#endregion
#endif
}
#endif

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 61838eb75b8164d699b0f54416e0f0bc
timeCreated: 1497347459
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,272 @@
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using ES3Internal;
/*
* ---- How Postprocessing works for the reference manager ----
* - When the manager is first added to the scene, all top-level dependencies are added to the manager (AddManagerToScene).
* - When the manager is first added to the scene, all prefabs with ES3Prefab components are added to the manager (AddManagerToScene).
* - All GameObjects and Components in the scene are added to the reference manager when we enter Playmode or the scene is saved (PlayModeStateChanged, OnWillSaveAssets -> AddGameObjectsAndComponentstoManager).
* - When a UnityEngine.Object field of a Component is modified, the new UnityEngine.Object reference is added to the reference manager (PostProcessModifications)
* - All prefabs with ES3Prefab Components are added to the reference manager when we enter Playmode or the scene is saved (PlayModeStateChanged, OnWillSaveAssets -> AddGameObjectsAndComponentstoManager).
* - Local references for prefabs are processed whenever a prefab with an ES3Prefab Component is deselected (SelectionChanged -> ProcessGameObject)
*/
[InitializeOnLoad]
public class ES3Postprocessor : UnityEditor.AssetModificationProcessor
{
public static ES3ReferenceMgr RefMgr
{
get { return (ES3ReferenceMgr)ES3ReferenceMgr.Current; }
}
public static GameObject lastSelected = null;
// This constructor is also called once when playmode is activated and whenever recompilation happens
// because we have the [InitializeOnLoad] attribute assigned to the class.
static ES3Postprocessor()
{
#if UNITY_2020_2_OR_NEWER
ObjectChangeEvents.changesPublished += Changed;
#endif
ObjectFactory.componentWasAdded += ComponentWasAdded;
// Open the Easy Save 3 window the first time ES3 is installed.
//ES3Editor.ES3Window.OpenEditorWindowOnStart();
EditorApplication.playModeStateChanged -= PlayModeStateChanged;
EditorApplication.playModeStateChanged += PlayModeStateChanged;
EditorSceneManager.sceneOpened += OnSceneOpened;
}
#region Reference Updating
private static void PlayModeStateChanged(PlayModeStateChange state)
{
if (state == PlayModeStateChange.ExitingEditMode)
UpdateAssembliesContainingES3Types();
}
private static void OnSceneOpened(Scene scene, OpenSceneMode mode)
{
if (mode == OpenSceneMode.AdditiveWithoutLoading || Application.isPlaying)
return;
if (ES3Settings.defaultSettingsScriptableObject.autoUpdateReferences && ES3Settings.defaultSettingsScriptableObject.updateReferencesWhenSceneIsOpened)
RefreshScene(scene);
}
private static void RefreshReferences(bool isEnteringPlayMode = false)
{
/*if (refreshed) // If we've already refreshed, do nothing.
return;*/
if (ES3Settings.defaultSettingsScriptableObject.autoUpdateReferences)
for (int i = 0; i < SceneManager.sceneCount; i++)
RefreshScene(SceneManager.GetSceneAt(i));
//refreshed = true;
}
static void RefreshScene(Scene scene, bool isEnteringPlayMode = false)
{
if (scene != null && scene.isLoaded)
{
var mgr = (ES3ReferenceMgr)ES3ReferenceMgr.GetManagerFromScene(scene);
if (mgr != null)
mgr.RefreshDependencies(isEnteringPlayMode);
}
}
static void ComponentWasAdded(Component c)
{
var scene = c.gameObject.scene;
if (!scene.isLoaded)
return;
var mgr = (ES3ReferenceMgr)ES3ReferenceMgr.GetManagerFromScene(scene);
if (mgr != null)
mgr.AddDependencies(c);
}
#if UNITY_2020_2_OR_NEWER
static void Changed(ref ObjectChangeEventStream stream)
{
if (EditorApplication.isUpdating || Application.isPlaying || !ES3Settings.defaultSettingsScriptableObject.autoUpdateReferences || !ES3Settings.defaultSettingsScriptableObject.updateReferencesWhenSceneChanges)
return;
for (int i = 0; i < stream.length; i++)
{
var eventType = stream.GetEventType(i);
int[] instanceIds;
Scene scene;
if (eventType == ObjectChangeKind.ChangeGameObjectOrComponentProperties)
{
ChangeGameObjectOrComponentPropertiesEventArgs evt;
stream.GetChangeGameObjectOrComponentPropertiesEvent(i, out evt);
instanceIds = new int[] { evt.instanceId };
scene = evt.scene;
}
else if (eventType == ObjectChangeKind.CreateGameObjectHierarchy)
{
CreateGameObjectHierarchyEventArgs evt;
stream.GetCreateGameObjectHierarchyEvent(i, out evt);
instanceIds = new int[] { evt.instanceId };
scene = evt.scene;
}
/*else if (eventType == ObjectChangeKind.ChangeAssetObjectProperties)
{
ChangeAssetObjectPropertiesEventArgs evt;
stream.GetChangeAssetObjectPropertiesEvent(i, out evt);
instanceIds = new int[] { evt.instanceId };
}*/
else if (eventType == ObjectChangeKind.UpdatePrefabInstances)
{
UpdatePrefabInstancesEventArgs evt;
stream.GetUpdatePrefabInstancesEvent(i, out evt);
instanceIds = evt.instanceIds.ToArray();
scene = evt.scene;
}
else
continue;
var mgr = (ES3ReferenceMgr)ES3ReferenceMgr.GetManagerFromScene(scene);
if (mgr == null)
return;
foreach (var id in instanceIds)
{
try
{
var obj = EditorUtility.InstanceIDToObject(id);
if (obj == null)
continue;
mgr.AddDependencies(obj);
}
catch { }
}
}
}
#endif
/*public static void PlayModeStateChanged(PlayModeStateChange state)
{
// Add all GameObjects and Components to the reference manager before we enter play mode.
if (state == PlayModeStateChange.ExitingEditMode && ES3Settings.defaultSettingsScriptableObject.autoUpdateReferences)
RefreshReferences(true);
}*/
public static string[] OnWillSaveAssets(string[] paths)
{
// Don't refresh references when the application is playing.
if (!EditorApplication.isUpdating && !Application.isPlaying)
{
if(ES3Settings.defaultSettingsScriptableObject.autoUpdateReferences && ES3Settings.defaultSettingsScriptableObject.updateReferencesWhenSceneIsSaved)
RefreshReferences();
UpdateAssembliesContainingES3Types();
}
return paths;
}
#endregion
private static void UpdateAssembliesContainingES3Types()
{
var assemblies = UnityEditor.Compilation.CompilationPipeline.GetAssemblies();
if (assemblies == null || assemblies.Length == 0)
return;
var defaults = ES3Settings.defaultSettingsScriptableObject;
var currentAssemblyNames = defaults.settings.assemblyNames;
var assemblyNames = new List<string>();
foreach (var assembly in assemblies)
{
// Don't include Editor assemblies.
if (assembly.flags.HasFlag(UnityEditor.Compilation.AssemblyFlags.EditorAssembly))
continue;
// Assemblies beginning with 'com.' are assumed to be internal.
if (assembly.name.StartsWith("com."))
continue;
// If this assembly begins with 'Unity', but isn't created from an Assembly Definition File, skip it.
if (assembly.name.StartsWith("Unity"))
{
bool isAssemblyDefinition = true;
foreach (string sourceFile in assembly.sourceFiles)
{
if (!sourceFile.StartsWith("Assets/"))
{
isAssemblyDefinition = false;
break;
}
}
if (!isAssemblyDefinition)
continue;
}
assemblyNames.Add(assembly.name);
}
// If there are no assembly names,
if (assemblyNames.Count == 0)
return;
// Sort it alphabetically so that the order isn't constantly changing, which can affect version control.
assemblyNames.Sort();
// Only update if the list has changed.
for (int i = 0; i < assemblyNames.Count; i++)
{
if (currentAssemblyNames.Length != assemblyNames.Count || currentAssemblyNames[i] != assemblyNames[i])
{
defaults.settings.assemblyNames = assemblyNames.ToArray();
EditorUtility.SetDirty(defaults);
break;
}
}
}
public static GameObject AddManagerToScene()
{
GameObject mgr = null;
if (RefMgr != null)
mgr = RefMgr.gameObject;
if (mgr == null)
mgr = new GameObject("Easy Save 3 Manager");
if (mgr.GetComponent<ES3ReferenceMgr>() == null)
{
mgr.AddComponent<ES3ReferenceMgr>();
if (!Application.isPlaying && ES3Settings.defaultSettingsScriptableObject.autoUpdateReferences)
RefMgr.RefreshDependencies();
}
if (mgr.GetComponent<ES3AutoSaveMgr>() == null)
mgr.AddComponent<ES3AutoSaveMgr>();
Undo.RegisterCreatedObjectUndo(mgr, "Enabled Easy Save for Scene");
return mgr;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4256380692bcb4e57bdc0a5e13956389
timeCreated: 1474041535
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using System;
using System.Collections;
using ES3Internal;
[CustomEditor(typeof(ES3Prefab))]
[System.Serializable]
public class ES3PrefabEditor : Editor
{
bool showAdvanced = false;
bool openLocalRefs = false;
public override void OnInspectorGUI()
{
var es3Prefab = (ES3Prefab)serializedObject.targetObject;
EditorGUILayout.HelpBox("Easy Save is enabled for this prefab, and can be saved and loaded with the ES3 methods.", MessageType.None);
showAdvanced = EditorGUILayout.Foldout(showAdvanced, "Advanced Settings");
if(showAdvanced)
{
EditorGUI.indentLevel++;
es3Prefab.prefabId = EditorGUILayout.LongField("Prefab ID", es3Prefab.prefabId);
EditorGUILayout.LabelField("Reference count", es3Prefab.localRefs.Count.ToString());
EditorGUI.indentLevel--;
openLocalRefs = EditorGUILayout.Foldout(openLocalRefs, "localRefs");
if (openLocalRefs)
{
EditorGUI.indentLevel++;
EditorGUILayout.LabelField("It is not recommended to manually modify these.");
foreach (var kvp in es3Prefab.localRefs)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.ObjectField(kvp.Key, typeof(UnityEngine.Object), false);
EditorGUILayout.LongField(kvp.Value);
EditorGUILayout.EndHorizontal();
}
EditorGUI.indentLevel--;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9d25610c9233c4cdfa5a0744c9956f5c
timeCreated: 1519132292
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,219 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using System;
using System.Collections;
using System.Collections.Generic;
[CustomEditor(typeof(ES3ReferenceMgr))]
[System.Serializable]
public class ES3ReferenceMgrEditor : Editor
{
private bool isDraggingOver = false;
private bool openReferences = false;
private ES3ReferenceMgr _mgr = null;
private ES3ReferenceMgr mgr
{
get
{
if (_mgr == null)
_mgr = (ES3ReferenceMgr)serializedObject.targetObject;
return _mgr;
}
}
public override void OnInspectorGUI()
{
EditorGUILayout.HelpBox("This allows Easy Save to maintain references to objects in your scene.\n\nIt is automatically updated when you enter Playmode or build your project.", MessageType.Info);
if (EditorGUILayout.Foldout(openReferences, "References") != openReferences)
{
openReferences = !openReferences;
if (openReferences == true)
openReferences = EditorUtility.DisplayDialog("Are you sure?", "Opening this list will display every reference in the manager, which for larger projects can cause the Editor to freeze\n\nIt is strongly recommended that you save your project before continuing.", "Open References", "Cancel");
}
// Make foldout drag-and-drop enabled for objects.
if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
{
Event evt = Event.current;
switch (evt.type)
{
case EventType.DragUpdated:
case EventType.DragPerform:
isDraggingOver = true;
break;
case EventType.DragExited:
isDraggingOver = false;
break;
}
if (isDraggingOver)
{
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
if (evt.type == EventType.DragPerform)
{
DragAndDrop.AcceptDrag();
Undo.RecordObject(mgr, "Add References to Easy Save 3 Reference List");
foreach (UnityEngine.Object obj in DragAndDrop.objectReferences)
mgr.Add(obj);
// Return now because otherwise we'll change the GUI during an event which doesn't allow it.
return;
}
}
}
if (openReferences)
{
EditorGUI.indentLevel++;
foreach (var kvp in mgr.idRef)
{
EditorGUILayout.BeginHorizontal();
var value = EditorGUILayout.ObjectField(kvp.Value, typeof(UnityEngine.Object), true);
var key = EditorGUILayout.LongField(kvp.Key);
EditorGUILayout.EndHorizontal();
if (value != kvp.Value || key != kvp.Key)
{
Undo.RecordObject(mgr, "Change Easy Save 3 References");
// If we're deleting a value, delete it.
if (value == null)
mgr.Remove(key);
// Else, update the ID.
else
mgr.ChangeId(kvp.Key, key);
// Break, as removing or changing Dictionary items will make the foreach out of sync.
break;
}
}
EditorGUI.indentLevel--;
}
mgr.openPrefabs = EditorGUILayout.Foldout(mgr.openPrefabs, "ES3Prefabs");
if (mgr.openPrefabs)
{
EditorGUI.indentLevel++;
foreach (var prefab in mgr.prefabs)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.ObjectField(prefab, typeof(UnityEngine.Object), true);
EditorGUILayout.EndHorizontal();
}
EditorGUI.indentLevel--;
}
var sp = serializedObject.FindProperty("excludeObjects");
EditorGUILayout.PropertyField(sp);
serializedObject.ApplyModifiedProperties();
EditorGUILayout.LabelField("Reference count", mgr.refId.Count.ToString());
EditorGUILayout.LabelField("Prefab count", mgr.prefabs.Count.ToString());
if (GUILayout.Button("Refresh"))
{
mgr.RefreshDependencies();
}
if (GUILayout.Button("Optimize"))
{
mgr.Optimize();
}
}
[MenuItem("GameObject/Easy Save 3/Add Reference(s) to Manager", false, 33)]
[MenuItem("Assets/Easy Save 3/Add Reference(s) to Manager", false, 33)]
public static void AddReferenceToManager()
{
var mgr = ES3ReferenceMgr.Current;
if (mgr == null)
{
EditorUtility.DisplayDialog("Could not add reference to manager", "This object could not be added to the reference manager because no reference manager exists in this scene. To create one, go to Tools > Easy Save 3 > Add Manager to Scene", "Ok");
return;
}
var selected = Selection.GetFiltered<UnityEngine.Object>(SelectionMode.DeepAssets);
if (selected == null || selected.Length == 0)
return;
Undo.RecordObject(mgr, "Update Easy Save 3 Reference Manager");
foreach (var obj in selected)
{
if (obj == null)
continue;
if (obj.GetType() == typeof(GameObject))
{
var go = (GameObject)obj;
if (ES3EditorUtility.IsPrefabInAssets(go) && go.GetComponent<ES3Internal.ES3Prefab>() != null)
mgr.AddPrefab(go.GetComponent<ES3Internal.ES3Prefab>());
}
((ES3ReferenceMgr)mgr).AddDependencies(obj);
}
}
[MenuItem("GameObject/Easy Save 3/Add Reference(s) to Manager", true, 33)]
[MenuItem("Assets/Easy Save 3/Add Reference(s) to Manager", true, 33)]
private static bool CanAddReferenceToManager()
{
var selected = Selection.GetFiltered<UnityEngine.Object>(SelectionMode.Deep);
return selected != null && selected.Length > 0 && ES3ReferenceMgr.Current != null;
}
[MenuItem("GameObject/Easy Save 3/Exclude Reference(s) from Manager", false, 33)]
[MenuItem("Assets/Easy Save 3/Exclude Reference(s) from Manager", false, 33)]
public static void ExcludeReferenceFromManager()
{
var mgr = (ES3ReferenceMgr)ES3ReferenceMgr.Current;
if (mgr == null)
{
EditorUtility.DisplayDialog("Could not exclude reference from manager", "This object could not be excluded from the reference manager because no reference manager exists in this scene. To create one, go to Tools > Easy Save 3 > Add Manager to Scene", "Ok");
return;
}
var selected = Selection.GetFiltered<UnityEngine.Object>(SelectionMode.DeepAssets);
if (selected == null || selected.Length == 0)
return;
Undo.RecordObject(mgr, "Exclude from Easy Save 3 Reference Manager");
if (mgr.excludeObjects == null)
mgr.excludeObjects = new List<UnityEngine.Object>();
mgr.excludeObjects.AddRange(EditorUtility.CollectDependencies(selected));
mgr.RemoveNullOrInvalidValues();
}
[MenuItem("GameObject/Easy Save 3/Add Manager to Scene", false, 33)]
[MenuItem("Assets/Easy Save 3/Add Manager to Scene", false, 33)]
[MenuItem("Tools/Easy Save 3/Add Manager to Scene", false, 150)]
public static void EnableForScene()
{
if(!SceneManager.GetActiveScene().isLoaded)
EditorUtility.DisplayDialog("Could not add manager to scene", "Could not add Easy Save 3 Manager to scene because there is not currently a scene open.", "Ok");
Selection.activeObject = ES3Postprocessor.AddManagerToScene();
}
[MenuItem("GameObject/Easy Save 3/Add Manager to Scene", true, 33)]
[MenuItem("Assets/Easy Save 3/Add Manager to Scene", true, 33)]
[MenuItem("Tools/Easy Save 3/Add Manager to Scene", true, 150)]
private static bool CanEnableForScene()
{
return ES3ReferenceMgr.GetManagerFromScene(SceneManager.GetActiveScene()) == null;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3b43d266ed3464dedaa77757645ad61c
timeCreated: 1519132283
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,47 @@
using System;
using UnityEngine;
namespace ES3Types
{
[UnityEngine.Scripting.Preserve]
[ES3PropertiesAttribute([propertyNames])]
public class ES3UserType_[es3TypeSuffix] : ES3ScriptableObjectType
{
public static ES3Type Instance = null;
public ES3UserType_[es3TypeSuffix]() : base(typeof([fullType])){ Instance = this; priority = 1; }
protected override void WriteScriptableObject(object obj, ES3Writer writer)
{
var instance = ([fullType])obj;
[writes]
}
protected override void ReadScriptableObject<T>(ES3Reader reader, object obj)
{
var instance = ([fullType])obj;
foreach(string propertyName in reader.Properties)
{
switch(propertyName)
{
[reads]
default:
reader.Skip();
break;
}
}
}
}
public class ES3UserType_[es3TypeSuffix]Array : ES3ArrayType
{
public static ES3Type Instance;
public ES3UserType_[es3TypeSuffix]Array() : base(typeof([fullType][]), ES3UserType_[es3TypeSuffix].Instance)
{
Instance = this;
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3b4ae594e55834c35b197df04c2e81cb
timeCreated: 1483698819
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,76 @@
using UnityEditor;
using UnityEngine;
using UnityEditor.Build;
using System.Collections.Generic;
using UnityEditor.Compilation;
using System.Reflection;
using System.Linq;
using System;
[InitializeOnLoad]
public class ES3ScriptingDefineSymbols
{
static ES3ScriptingDefineSymbols()
{
SetDefineSymbols();
}
static void SetDefineSymbols()
{
if (Type.GetType("Unity.VisualScripting.IncludeInSettingsAttribute, Unity.VisualScripting.Core") != null)
SetDefineSymbol("UNITY_VISUAL_SCRIPTING");
if (Type.GetType("Ludiq.IncludeInSettingsAttribute, Ludiq.Core.Runtime") != null)
SetDefineSymbol("BOLT_VISUAL_SCRIPTING");
}
static void SetDefineSymbol(string symbol)
{
#if UNITY_2021_2_OR_NEWER
foreach (var target in GetAllNamedBuildTargets())
{
string[] defines;
try
{
PlayerSettings.GetScriptingDefineSymbols(target, out defines);
if (!defines.Contains(symbol))
{
ArrayUtility.Add(ref defines, symbol);
PlayerSettings.SetScriptingDefineSymbols(target, defines);
}
}
catch { }
}
#else
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
var allDefines = new HashSet<string>(definesString.Split(';'));
if (!allDefines.Contains(symbol))
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, string.Join(";", allDefines.Concat(new string[] { symbol }).ToArray()));
#endif
return;
}
#if UNITY_2021_2_OR_NEWER
static List<NamedBuildTarget> GetAllNamedBuildTargets()
{
var staticFields = typeof(NamedBuildTarget).GetFields(BindingFlags.Public | BindingFlags.Static);
var buildTargets = new List<NamedBuildTarget>();
foreach (var staticField in staticFields)
{
// We exclude 'Unknown' because this can throw errors when used with certain methods.
if (staticField.Name == "Unknown")
continue;
// A bug at Unity's end means that Stadia can throw an error.
if (staticField.Name == "Stadia")
continue;
if (staticField.FieldType == typeof(NamedBuildTarget))
buildTargets.Add((NamedBuildTarget)staticField.GetValue(null));
}
return buildTargets;
}
#endif
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 69b6276384d46d34fb2705f95689e8cc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,56 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using System;
using System.Collections;
using ES3Internal;
namespace ES3Editor
{
public static class ES3SettingsEditor
{
public static void Draw(ES3SerializableSettings settings)
{
var style = EditorStyle.Get;
settings.location = (ES3.Location)EditorGUILayout.EnumPopup("Location", settings.location);
// If the location is File, show the Directory.
if(settings.location == ES3.Location.File)
settings.directory = (ES3.Directory)EditorGUILayout.EnumPopup("Directory", settings.directory);
settings.path = EditorGUILayout.TextField("Default File Path", settings.path);
EditorGUILayout.Space();
settings.encryptionType = (ES3.EncryptionType)EditorGUILayout.EnumPopup("Encryption", settings.encryptionType);
settings.encryptionPassword = EditorGUILayout.TextField("Encryption Password", settings.encryptionPassword);
EditorGUILayout.Space();
settings.compressionType = (ES3.CompressionType)EditorGUILayout.EnumPopup("Compression", settings.compressionType);
EditorGUILayout.Space();
settings.saveChildren = EditorGUILayout.Toggle("Save GameObject Children", settings.saveChildren);
EditorGUILayout.Space();
if(settings.showAdvancedSettings = EditorGUILayout.Foldout(settings.showAdvancedSettings, "Advanced Settings"))
{
EditorGUILayout.BeginVertical(style.area);
settings.format = (ES3.Format)EditorGUILayout.EnumPopup("Format", settings.format);
if (settings.format == ES3.Format.JSON)
settings.prettyPrint = EditorGUILayout.Toggle(new GUIContent("Pretty print JSON"), settings.prettyPrint);
settings.bufferSize = EditorGUILayout.IntField("Buffer Size", settings.bufferSize);
settings.memberReferenceMode = (ES3.ReferenceMode)EditorGUILayout.EnumPopup("Serialise Unity Object fields", settings.memberReferenceMode);
settings.serializationDepthLimit = EditorGUILayout.IntField("Serialisation Depth", settings.serializationDepthLimit);
settings.postprocessRawCachedData = EditorGUILayout.Toggle(new GUIContent("Postprocess raw cached data"), settings.postprocessRawCachedData);
EditorGUILayout.Space();
EditorGUILayout.EndVertical();
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 35659b9a083a341d7bee216c4b71f4bc
timeCreated: 1519132282
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
using System;
using UnityEngine;
namespace ES3Types
{
[UnityEngine.Scripting.Preserve]
[ES3PropertiesAttribute([propertyNames])]
public class ES3UserType_[es3TypeSuffix] : ES3Type
{
public static ES3Type Instance = null;
public ES3UserType_[es3TypeSuffix]() : base(typeof([fullType])){ Instance = this; priority = 1;}
public override void Write(object obj, ES3Writer writer)
{
var instance = ([fullType])obj;
[writes]
}
public override object Read<T>(ES3Reader reader)
{
var instance = new [fullType]();
ReadInto<T>(reader, instance);
return instance;
}
public override void ReadInto<T>(ES3Reader reader, object obj)
{
var instance = ([fullType])obj;
string propertyName;
while((propertyName = reader.ReadPropertyName()) != null)
{
switch(propertyName)
{
[reads]
default:
reader.Skip();
break;
}
}
}
}
public class ES3UserType_[es3TypeSuffix]Array : ES3ArrayType
{
public static ES3Type Instance;
public ES3UserType_[es3TypeSuffix]Array() : base(typeof([fullType][]), ES3UserType_[es3TypeSuffix].Instance)
{
Instance = this;
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e84ec2bd739f543b0a5cd3c13741f744
timeCreated: 1483718243
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,62 @@
using System;
using UnityEngine;
namespace ES3Types
{
[UnityEngine.Scripting.Preserve]
public class ES3UserType_Material : ES3UnityObjectType
{
public static ES3Type Instance = null;
public ES3UserType_Material() : base(typeof(UnityEngine.Material)){ Instance = this; priority = 1; }
protected override void WriteUnityObject(object obj, ES3Writer writer)
{
var instance = (UnityEngine.Material)obj;
writer.WriteProperty("shader", instance.shader);
writer.WriteProperty("renderQueue", instance.renderQueue, ES3Type_int.Instance);
writer.WriteProperty("shaderKeywords", instance.shaderKeywords);
writer.WriteProperty("globalIlluminationFlags", instance.globalIlluminationFlags);
[writes]
}
protected override object ReadUnityObject<T>(ES3Reader reader)
{
var obj = new Material(Shader.Find("Diffuse"));
ReadUnityObject<T>(reader, obj);
return obj;
}
protected override void ReadUnityObject<T>(ES3Reader reader, object obj)
{
var instance = (UnityEngine.Material)obj;
foreach(string propertyName in reader.Properties)
{
switch(propertyName)
{
case "name":
instance.name = reader.Read<string>(ES3Type_string.Instance);
break;
case "shader":
instance.shader = reader.Read<UnityEngine.Shader>(ES3Type_Shader.Instance);
break;
case "renderQueue":
instance.renderQueue = reader.Read<System.Int32>(ES3Type_int.Instance);
break;
case "shaderKeywords":
instance.shaderKeywords = reader.Read<System.String[]>();
break;
case "globalIlluminationFlags":
instance.globalIlluminationFlags = reader.Read<UnityEngine.MaterialGlobalIlluminationFlags>();
break;
[reads]
default:
reader.Skip();
break;
}
}
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f90b0399488ef42e5bc804122fd99c58
timeCreated: 1483698819
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
using System;
using UnityEngine;
namespace ES3Types
{
[UnityEngine.Scripting.Preserve]
[ES3PropertiesAttribute([propertyNames])]
public class ES3UserType_[es3TypeSuffix] : ES3Type
{
public static ES3Type Instance = null;
public ES3UserType_[es3TypeSuffix]() : base(typeof([fullType])){ Instance = this; priority = 1;}
public override void Write(object obj, ES3Writer writer)
{
var instance = ([fullType])obj;
[writes]
}
public override object Read<T>(ES3Reader reader)
{
var instance = new [fullType]();
string propertyName;
while((propertyName = reader.ReadPropertyName()) != null)
{
switch(propertyName)
{
[reads]
default:
reader.Skip();
break;
}
}
return instance;
}
}
public class ES3UserType_[es3TypeSuffix]Array : ES3ArrayType
{
public static ES3Type Instance;
public ES3UserType_[es3TypeSuffix]Array() : base(typeof([fullType][]), ES3UserType_[es3TypeSuffix].Instance)
{
Instance = this;
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f67742ea0c50242f8af16c3f807b723b
timeCreated: 1483718243
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,238 @@
using UnityEngine;
using UnityEditor;
using System.Linq;
namespace ES3Editor
{
public class ES3Window : EditorWindow
{
private SubWindow[] windows = null;
public SubWindow currentWindow;
[MenuItem("Window/Easy Save 3", false, 1000)]
[MenuItem("Assets/Easy Save 3/Open Easy Save 3 Window", false, 1000)]
public static void Init()
{
// Get existing open window or if none, make a new one:
ES3Window window = (ES3Window)EditorWindow.GetWindow(typeof(ES3Window));
if(window != null)
window.Show();
}
public static void InitAndShowHome()
{
// Get existing open window or if none, make a new one:
ES3Window window = (ES3Window)EditorWindow.GetWindow(typeof(ES3Window));
if (window != null)
{
window.Show();
window.SetCurrentWindow(typeof(HomeWindow));
}
}
[MenuItem("Tools/Easy Save 3/Auto Save", false, 100)]
public static void InitAndShowAutoSave()
{
// Get existing open window or if none, make a new one:
ES3Window window = (ES3Window)EditorWindow.GetWindow(typeof(ES3Window));
if (window != null)
{
window.Show();
window.SetCurrentWindow(typeof(AutoSaveWindow));
}
}
public static void InitAndShowReferences()
{
// Get existing open window or if none, make a new one:
ES3Window window = (ES3Window)EditorWindow.GetWindow(typeof(ES3Window));
if (window != null)
{
window.Show();
window.SetCurrentWindow(typeof(ReferencesWindow));
}
}
[MenuItem("Tools/Easy Save 3/Types", false, 100)]
public static void InitAndShowTypes()
{
// Get existing open window or if none, make a new one:
ES3Window window = (ES3Window)EditorWindow.GetWindow(typeof(ES3Window));
if (window != null)
{
window.Show();
window.SetCurrentWindow(typeof(TypesWindow));
}
}
public static void InitAndShowTypes(System.Type type)
{
// Get existing open window or if none, make a new one:
ES3Window window = (ES3Window)EditorWindow.GetWindow(typeof(ES3Window));
if (window != null)
{
window.Show();
var typesWindow = (TypesWindow)window.SetCurrentWindow(typeof(TypesWindow));
typesWindow.SelectType(type);
}
}
[MenuItem("Tools/Easy Save 3/Settings", false, 100)]
public static void InitAndShowSettings()
{
// Get existing open window or if none, make a new one:
ES3Window window = (ES3Window)EditorWindow.GetWindow(typeof(ES3Window));
if (window != null)
{
window.Show();
window.SetCurrentWindow(typeof(SettingsWindow));
}
}
[MenuItem("Tools/Easy Save 3/Tools", false, 100)]
public static void InitAndShowTools()
{
// Get existing open window or if none, make a new one:
ES3Window window = (ES3Window)EditorWindow.GetWindow(typeof(ES3Window));
if (window != null)
{
window.Show();
window.SetCurrentWindow(typeof(ToolsWindow));
}
}
public void InitSubWindows()
{
windows = new SubWindow[]{
new HomeWindow(this),
new SettingsWindow(this),
new ToolsWindow(this),
new TypesWindow(this),
new AutoSaveWindow(this)
//, new ReferencesWindow(this)
};
}
void OnLostFocus()
{
if(currentWindow != null)
currentWindow.OnLostFocus();
}
private void OnFocus()
{
if (currentWindow != null)
currentWindow.OnFocus();
}
void OnDestroy()
{
if(currentWindow != null)
currentWindow.OnDestroy();
}
void OnEnable()
{
if(windows == null)
InitSubWindows();
// Set the window name and icon.
var icon = AssetDatabase.LoadAssetAtPath<Texture2D>(ES3Settings.PathToEasySaveFolder()+"Editor/es3Logo16x16.png");
titleContent = new GUIContent("Easy Save", icon);
// Get the last opened window and open it.
if(currentWindow == null)
{
var currentWindowName = EditorPrefs.GetString("ES3Editor.Window.currentWindow", windows[0].name);
for(int i=0; i<windows.Length; i++)
{
if(windows[i].name == currentWindowName)
{
currentWindow = windows[i];
break;
}
}
}
}
private void OnHierarchyChange()
{
if (currentWindow != null)
currentWindow.OnHierarchyChange();
}
void OnGUI()
{
var style = EditorStyle.Get;
// Display the menu.
EditorGUILayout.BeginHorizontal();
for(int i=0; i<windows.Length; i++)
{
if(GUILayout.Button(windows[i].name, currentWindow == windows[i] ? style.menuButtonSelected : style.menuButton))
SetCurrentWindow(windows[i]);
}
EditorGUILayout.EndHorizontal();
if(currentWindow != null)
currentWindow.OnGUI();
}
void SetCurrentWindow(SubWindow window)
{
if (currentWindow != null)
currentWindow.OnLostFocus();
currentWindow = window;
currentWindow.OnFocus();
EditorPrefs.SetString("ES3Editor.Window.currentWindow", window.name);
}
SubWindow SetCurrentWindow(System.Type type)
{
currentWindow.OnLostFocus();
currentWindow = windows.First(w => w.GetType() == type);
EditorPrefs.SetString("ES3Editor.Window.currentWindow", currentWindow.name);
return currentWindow;
}
// Shows the Easy Save Home window if it's not been disabled.
// This method is called from the Postprocessor.
public static void OpenEditorWindowOnStart()
{
if(EditorPrefs.GetBool("Show ES3 Window on Start", true))
ES3Window.InitAndShowHome();
EditorPrefs.SetBool("Show ES3 Window on Start", false);
}
}
public abstract class SubWindow
{
public string name;
public EditorWindow parent;
public abstract void OnGUI();
public SubWindow(string name, EditorWindow parent)
{
this.name = name;
this.parent = parent;
}
public virtual void OnLostFocus()
{
}
public virtual void OnFocus()
{
}
public virtual void OnDestroy()
{
}
public virtual void OnHierarchyChange()
{
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a95d98897f1cf4e7288b53b0fd8036c1
timeCreated: 1519132293
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
{
"name": "EasySave3",
"rootNamespace": "",
"references": [
"Unity.VisualScripting.Core"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6eac6c06328c1ab4dacdf5d40907da6b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
{
"name": "EasySave3Editor",
"rootNamespace": "",
"references": [
"EasySave3"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5c64090e866862f449075dc1f3e5ab06
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using UnityEditor;
using System.IO;
public class EnableES3AssemblyDefinitions : Editor
{
[MenuItem("Tools/Easy Save 3/Enable Assembly Definition Files", false, 150)]
public static void EnableAsmDef()
{
var pathToEasySaveFolder = ES3Settings.PathToEasySaveFolder();
File.Delete(pathToEasySaveFolder + "Editor/EasySave3.asmdef.disabled.meta");
File.Delete(pathToEasySaveFolder + "Editor/EasySave3Editor.asmdef.disabled.meta");
File.Move(pathToEasySaveFolder + "Editor/EasySave3Editor.asmdef.disabled", pathToEasySaveFolder + "Editor/EasySave3Editor.asmdef");
File.Move(pathToEasySaveFolder + "Editor/EasySave3.asmdef.disabled", pathToEasySaveFolder + "EasySave3.asmdef");
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
EditorUtility.DisplayDialog("Assembly definition files installed", "Assembly definition files for Easy Save 3 installed.\n\nYou may need to go to 'Assets > Reimport' to apply the changes.", "Done");
}
[MenuItem("Tools/Easy Save 3/Enable Assembly Definition Files", true, 150)]
public static bool CanEnableAsmDef()
{
return !File.Exists(ES3Settings.PathToEasySaveFolder() + "EasySave3.asmdef");
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f53975dae5ac26947856dd0b0bd3be7e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,70 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace ES3Editor
{
public class HomeWindow : SubWindow
{
Vector2 scrollPos = Vector2.zero;
public HomeWindow(EditorWindow window) : base("Home", window){}
public override void OnGUI()
{
var style = EditorStyle.Get;
scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
EditorGUILayout.BeginVertical(style.area);
GUILayout.Label("Welcome to Easy Save", style.heading);
EditorGUILayout.BeginVertical(style.area);
GUILayout.Label("New To Easy Save?", style.subheading);
EditorGUILayout.BeginVertical(style.area);
ES3EditorUtility.DisplayLink("• See our Getting Started guide", "http://docs.moodkie.com/easy-save-3/getting-started/");
EditorGUILayout.EndVertical();
GUILayout.Label("Support", style.subheading);
EditorGUILayout.BeginVertical(style.area);
ES3EditorUtility.DisplayLink("• Contact us directly", "http://www.moodkie.com/contact/");
ES3EditorUtility.DisplayLink("• Ask a question in our Easy Save 3 forums", "http://moodkie.com/forum/viewforum.php?f=12");
ES3EditorUtility.DisplayLink("• Ask a question in the Unity Forum thread","https://forum.unity3d.com/threads/easy-save-the-complete-save-load-asset-for-unity.91040/");
EditorGUILayout.EndVertical();
GUILayout.Label("Documentation and Guides", style.subheading);
EditorGUILayout.BeginVertical(style.area);
ES3EditorUtility.DisplayLink("• Documentation", "http://docs.moodkie.com/product/easy-save-3/");
ES3EditorUtility.DisplayLink("• Guides", "http://docs.moodkie.com/product/easy-save-3/es3-guides/");
ES3EditorUtility.DisplayLink("• API Scripting Reference", "http://docs.moodkie.com/product/easy-save-3/es3-api/");
ES3EditorUtility.DisplayLink("• Supported Types", "http://docs.moodkie.com/easy-save-3/es3-supported-types/");
EditorGUILayout.EndVertical();
GUILayout.Label("PlayMaker Documentation", style.subheading);
EditorGUILayout.BeginVertical(style.area);
ES3EditorUtility.DisplayLink("• Actions", "http://docs.moodkie.com/product/easy-save-3/es3-playmaker/es3-playmaker-actions/");
ES3EditorUtility.DisplayLink("• Actions Overview", "http://docs.moodkie.com/easy-save-3/es3-playmaker/playmaker-actions-overview/");
EditorGUILayout.EndVertical();
EditorGUILayout.EndVertical();
EditorGUILayout.EndVertical();
EditorGUILayout.EndScrollView();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 394cc2e77038849709526f44f7efdd22
timeCreated: 1519132283
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using ES3Internal;
namespace ES3Editor
{
public class ReferencesWindow : SubWindow
{
public ReferencesWindow(EditorWindow window) : base("References", window){}
public override void OnGUI()
{
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: af2d805793e784eef87fbcdebb11fa35
timeCreated: 1519132291
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,182 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using ES3Internal;
namespace ES3Editor
{
public class SettingsWindow : SubWindow
{
public ES3Defaults editorSettings = null;
public ES3SerializableSettings settings = null;
public SerializedObject so = null;
public SerializedProperty referenceFoldersProperty = null;
private Vector2 scrollPos = Vector2.zero;
public SettingsWindow(EditorWindow window) : base("Settings", window){}
public void OnEnable()
{
}
public override void OnGUI()
{
if(settings == null || editorSettings == null)
Init();
var style = EditorStyle.Get;
var labelWidth = EditorGUIUtility.labelWidth;
EditorGUI.BeginChangeCheck();
using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos, style.area))
{
scrollPos = scrollView.scrollPosition;
EditorGUIUtility.labelWidth = 160;
GUILayout.Label("Runtime Settings", style.heading);
using (new EditorGUILayout.VerticalScope(style.area))
{
ES3SettingsEditor.Draw(settings);
}
GUILayout.Label("Debug Settings", style.heading);
using (new EditorGUILayout.VerticalScope(style.area))
{
EditorGUIUtility.labelWidth = 100;
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.PrefixLabel("Log Info");
editorSettings.logDebugInfo = EditorGUILayout.Toggle(editorSettings.logDebugInfo);
}
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.PrefixLabel("Log Warnings");
editorSettings.logWarnings = EditorGUILayout.Toggle(editorSettings.logWarnings);
}
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.PrefixLabel("Log Errors");
editorSettings.logErrors = EditorGUILayout.Toggle(editorSettings.logErrors);
}
EditorGUILayout.Space();
}
GUILayout.Label("Editor Settings", style.heading);
using (new EditorGUILayout.VerticalScope(style.area))
{
EditorGUIUtility.labelWidth = 170;
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.PrefixLabel("Auto Update References");
editorSettings.autoUpdateReferences = EditorGUILayout.Toggle(editorSettings.autoUpdateReferences);
}
if (editorSettings.autoUpdateReferences)
{
using (new EditorGUILayout.HorizontalScope())
{
var content = new GUIContent("-- When changes are made", "Should Easy Save update the reference manager when objects in your scene changes?");
editorSettings.updateReferencesWhenSceneChanges = EditorGUILayout.Toggle(content, editorSettings.updateReferencesWhenSceneChanges);
}
using (new EditorGUILayout.HorizontalScope())
{
var content = new GUIContent("-- When scene is saved", "Should Easy Save update the reference manager when objects in your scene is saved?");
editorSettings.updateReferencesWhenSceneIsSaved = EditorGUILayout.Toggle(content, editorSettings.updateReferencesWhenSceneIsSaved);
}
using (new EditorGUILayout.HorizontalScope())
{
var content = new GUIContent("-- When scene is opened", "Should Easy Save update the reference manager you open a scene in the Editor?");
editorSettings.updateReferencesWhenSceneIsOpened = EditorGUILayout.Toggle(content, editorSettings.updateReferencesWhenSceneIsOpened);
}
EditorGUILayout.Space();
}
using (new EditorGUILayout.HorizontalScope())
{
so.Update();
EditorGUILayout.PropertyField(referenceFoldersProperty, true);
so.ApplyModifiedProperties();
}
EditorGUILayout.Space();
/*using (new EditorGUILayout.HorizontalScope())
{
var content = new GUIContent("Reference depth", "How deep should Easy Save look when gathering references from an object? Higher means deeper.");
EditorGUILayout.PrefixLabel(content);
editorSettings.collectDependenciesDepth = EditorGUILayout.IntField(editorSettings.collectDependenciesDepth);
}*/
using (new EditorGUILayout.HorizontalScope())
{
var content = new GUIContent("Reference timeout (seconds)", "How many seconds should Easy Save taking collecting references for an object before timing out?");
EditorGUILayout.PrefixLabel(content);
editorSettings.collectDependenciesTimeout = EditorGUILayout.IntField(editorSettings.collectDependenciesTimeout);
}
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.PrefixLabel("Use Global References");
var symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
bool useGlobalReferences = !symbols.Contains("ES3GLOBAL_DISABLED");
if(EditorGUILayout.Toggle(useGlobalReferences) != useGlobalReferences)
{
// Remove the existing symbol even if we're disabling global references, just incase it's already in there.
symbols = symbols.Replace("ES3GLOBAL_DISABLED;", ""); // With semicolon
symbols = symbols.Replace("ES3GLOBAL_DISABLED", ""); // Without semicolon
// Add the symbol if useGlobalReferences is currently true, meaning that we want to disable it.
if (useGlobalReferences)
symbols = "ES3GLOBAL_DISABLED;" + symbols;
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, symbols);
if(useGlobalReferences)
EditorUtility.DisplayDialog("Global references disabled for build platform", "This will only disable Global References for this build platform. To disable it for other build platforms, open that platform in the Build Settings and uncheck this box again.", "Ok");
}
}
using (new EditorGUILayout.HorizontalScope())
{
var content = new GUIContent("Add All Prefabs to Manager", "Should all prefabs with ES3Prefab Components be added to the manager?");
EditorGUILayout.PrefixLabel(content);
editorSettings.addAllPrefabsToManager = EditorGUILayout.Toggle(editorSettings.addAllPrefabsToManager);
}
EditorGUILayout.Space();
}
}
if (EditorGUI.EndChangeCheck())
EditorUtility.SetDirty(editorSettings);
EditorGUIUtility.labelWidth = labelWidth; // Set the label width back to default
}
public void Init()
{
editorSettings = ES3Settings.defaultSettingsScriptableObject;
settings = editorSettings.settings;
so = new SerializedObject(editorSettings);
referenceFoldersProperty = so.FindProperty("referenceFolders");
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 95e7bbc9a5aee44feb088811fb5e7b80
timeCreated: 1519132291
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,155 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
namespace ES3Editor
{
public class ToolsWindow : SubWindow
{
public ToolsWindow(EditorWindow window) : base("Tools", window){}
public override void OnGUI()
{
var style = EditorStyle.Get;
EditorGUILayout.BeginHorizontal(style.area);
if (GUILayout.Button("Open Persistent Data Path"))
OpenPersistentDataPath();
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal(style.area);
if (GUILayout.Button("Clear Persistent Data Path"))
ClearPersistentDataPath();
if (GUILayout.Button("Clear PlayerPrefs"))
ClearPlayerPrefs();
EditorGUILayout.EndHorizontal();
}
[MenuItem("Tools/Easy Save 3/Open Persistent Data Path", false, 200)]
private static void OpenPersistentDataPath()
{
EditorUtility.RevealInFinder(Application.persistentDataPath);
}
[MenuItem("Tools/Easy Save 3/Clear Persistent Data Path", false, 200)]
private static void ClearPersistentDataPath()
{
if (EditorUtility.DisplayDialog("Clear Persistent Data Path", "Are you sure you wish to clear the persistent data path?\n This action cannot be reversed.", "Clear", "Cancel"))
{
System.IO.DirectoryInfo di = new DirectoryInfo(Application.persistentDataPath);
foreach (FileInfo file in di.GetFiles())
file.Delete();
foreach (DirectoryInfo dir in di.GetDirectories())
dir.Delete(true);
}
}
[MenuItem("Tools/Easy Save 3/Clear PlayerPrefs", false, 200)]
private static void ClearPlayerPrefs()
{
if (EditorUtility.DisplayDialog("Clear PlayerPrefs", "Are you sure you wish to clear PlayerPrefs?\nThis action cannot be reversed.", "Clear", "Cancel"))
PlayerPrefs.DeleteAll();
}
}
/*public static class OSFileBrowser
{
public static bool IsInMacOS
{
get
{
return UnityEngine.SystemInfo.operatingSystem.IndexOf("Mac OS") != -1;
}
}
public static bool IsInWinOS
{
get
{
return UnityEngine.SystemInfo.operatingSystem.IndexOf("Windows") != -1;
}
}
public static void OpenInMac(string path)
{
bool openInsidesOfFolder = false;
// try mac
string macPath = path.Replace("\\", "/"); // mac finder doesn't like backward slashes
if ( System.IO.Directory.Exists(macPath) ) // if path requested is a folder, automatically open insides of that folder
{
openInsidesOfFolder = true;
}
if ( !macPath.StartsWith("\"") )
{
macPath = "\"" + macPath;
}
if ( !macPath.EndsWith("\"") )
{
macPath = macPath + "\"";
}
string arguments = (openInsidesOfFolder ? "" : "-R ") + macPath;
try
{
System.Diagnostics.Process.Start("open", arguments);
}
catch ( System.ComponentModel.Win32Exception e )
{
// tried to open mac finder in windows
// just silently skip error
// we currently have no platform define for the current OS we are in, so we resort to this
e.HelpLink = ""; // do anything with this variable to silence warning about not using it
}
}
public static void OpenInWin(string path)
{
bool openInsidesOfFolder = false;
// try windows
string winPath = path.Replace("/", "\\"); // windows explorer doesn't like forward slashes
if ( System.IO.Directory.Exists(winPath) ) // if path requested is a folder, automatically open insides of that folder
openInsidesOfFolder = true;
try
{
System.Diagnostics.Process.Start("explorer.exe", (openInsidesOfFolder ? "/root," : "/select,") + "\"" + winPath + "\"");
}
catch ( System.ComponentModel.Win32Exception e )
{
e.HelpLink = "";
}
}
public static void Open(string path)
{
if ( IsInWinOS )
{
OpenInWin(path);
}
else if ( IsInMacOS )
{
OpenInMac(path);
}
else // couldn't determine OS
{
OpenInWin(path);
OpenInMac(path);
}
}
}*/
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0d6114c1d40624e9e8575e814c45ac1a
timeCreated: 1519132280
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,726 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
using System.Reflection;
using System.Linq;
using ES3Types;
using System.IO;
using ES3Internal;
using System.Text.RegularExpressions;
namespace ES3Editor
{
public class TypesWindow : SubWindow
{
TypeListItem[] types = null;
const int recentTypeCount = 5;
List<int> recentTypes = null;
Vector2 typeListScrollPos = Vector2.zero;
Vector2 typePaneScrollPos = Vector2.zero;
int leftPaneWidth = 300;
string searchFieldValue = "";
int selectedType = -1;
private ES3Reflection.ES3ReflectedMember[] fields = new ES3Reflection.ES3ReflectedMember[0];
private bool[] fieldSelected = new bool[0];
private Texture2D checkmark;
//private Texture2D checkmarkSmall;
private GUIStyle searchBarStyle;
private GUIStyle searchBarCancelButtonStyle;
private GUIStyle leftPaneStyle;
private GUIStyle typeButtonStyle;
private GUIStyle selectedTypeButtonStyle;
private GUIStyle selectAllNoneButtonStyle;
private string valueTemplateFile;
private string classTemplateFile;
private string componentTemplateFile;
private string scriptableObjectTemplateFile;
private bool unsavedChanges = false;
public TypesWindow(EditorWindow window) : base("Types", window){}
public override void OnGUI()
{
if(types == null)
Init();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.BeginVertical(leftPaneStyle);
SearchBar();
TypeList();
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical();
TypePane();
EditorGUILayout.EndVertical();
EditorGUILayout.EndHorizontal();
}
private void SearchBar()
{
var style = EditorStyle.Get;
GUILayout.Label("Enter a type name in the field below\n* Type names are case-sensitive *", style.subheading2);
EditorGUILayout.BeginHorizontal();
// Set control name so we can force a Focus reset for it.
string currentSearchFieldValue = EditorGUILayout.TextField(searchFieldValue, searchBarStyle);
if(searchFieldValue != currentSearchFieldValue)
{
searchFieldValue = currentSearchFieldValue;
PerformSearch(currentSearchFieldValue);
}
GUI.SetNextControlName("Clear");
if(GUILayout.Button("x", searchBarCancelButtonStyle))
{
searchFieldValue = "";
GUI.FocusControl("Clear");
PerformSearch("");
}
EditorGUILayout.EndHorizontal();
}
private void RecentTypeList()
{
if(!string.IsNullOrEmpty(searchFieldValue) || recentTypes.Count == 0)
return;
for(int i=recentTypes.Count-1; i>-1; i--)
TypeButton(recentTypes[i]);
EditorGUILayout.TextArea("",GUI.skin.horizontalSlider);
}
private void TypeList()
{
if(!string.IsNullOrEmpty(searchFieldValue))
GUILayout.Label("Search Results", EditorStyles.boldLabel);
typeListScrollPos = EditorGUILayout.BeginScrollView(typeListScrollPos);
RecentTypeList();
if(!string.IsNullOrEmpty(searchFieldValue))
for(int i = 0; i < types.Length; i++)
TypeButton(i);
EditorGUILayout.EndScrollView();
}
private void TypePane()
{
if(selectedType < 0)
return;
var style = EditorStyle.Get;
var typeListItem = types[selectedType];
var type = typeListItem.type;
typePaneScrollPos = EditorGUILayout.BeginScrollView(typePaneScrollPos, style.area);
GUILayout.Label(typeListItem.name, style.subheading);
GUILayout.Label(typeListItem.namespaceName);
EditorGUILayout.BeginVertical(style.area);
bool hasParameterlessConstructor = ES3Reflection.HasParameterlessConstructor(type);
bool isComponent = ES3Reflection.IsAssignableFrom(typeof(Component), type);
string path = GetOutputPath(types[selectedType].type);
// An ES3Type file already exists.
if(File.Exists(path))
{
if(hasParameterlessConstructor || isComponent)
{
EditorGUILayout.BeginHorizontal();
if(GUILayout.Button("Reset to Default"))
{
SelectNone(true, true);
AssetDatabase.MoveAssetToTrash("Assets" + path.Remove(0, Application.dataPath.Length));
SelectType(selectedType);
}
if(GUILayout.Button("Edit ES3Type Script"))
AssetDatabase.OpenAsset(AssetDatabase.LoadMainAssetAtPath("Assets" + path.Remove(0, Application.dataPath.Length)));
EditorGUILayout.EndHorizontal();
}
else
{
EditorGUILayout.HelpBox("This type has no public parameterless constructors.\n\nTo support this type you will need to modify the ES3Type script to use a specific constructor instead of the parameterless constructor.", MessageType.Info);
if(GUILayout.Button("Click here to edit the ES3Type script"))
AssetDatabase.OpenAsset(AssetDatabase.LoadMainAssetAtPath("Assets" + path.Remove(0, Application.dataPath.Length)));
if (GUILayout.Button("Reset to Default"))
{
SelectAll(true, true);
File.Delete(path);
AssetDatabase.Refresh();
}
}
}
// No ES3Type file and no fields.
else if(fields.Length == 0)
{
if(!hasParameterlessConstructor && !isComponent)
EditorGUILayout.HelpBox("This type has no public parameterless constructors.\n\nTo support this type you will need to create an ES3Type script and modify it to use a specific constructor instead of the parameterless constructor.", MessageType.Info);
if(GUILayout.Button("Create ES3Type Script"))
Generate();
}
// No ES3Type file, but fields are selectable.
else
{
if(!hasParameterlessConstructor && !isComponent)
{
EditorGUILayout.HelpBox("This type has no public parameterless constructors.\n\nTo support this type you will need to select the fields you wish to serialize below, and then modify the generated ES3Type script to use a specific constructor instead of the parameterless constructor.", MessageType.Info);
if(GUILayout.Button("Select all fields and generate ES3Type script"))
{
SelectAll(true, false);
Generate();
}
}
else
{
if(GUILayout.Button("Create ES3Type Script"))
Generate();
}
}
EditorGUILayout.EndVertical();
PropertyPane();
EditorGUILayout.EndScrollView();
}
private void PropertyPane()
{
var style = EditorStyle.Get;
EditorGUILayout.BeginVertical(style.area);
GUILayout.Label("Fields", EditorStyles.boldLabel);
DisplayFieldsOrProperties(true, false);
EditorGUILayout.Space();
GUILayout.Label("Properties", EditorStyles.boldLabel);
DisplayFieldsOrProperties(false, true);
EditorGUILayout.EndVertical();
}
private void DisplayFieldsOrProperties(bool showFields, bool showProperties)
{
// Get field and property counts.
int fieldCount = 0;
int propertyCount = 0;
for(int i=0; i<fields.Length; i++)
{
if(fields[i].isProperty && showProperties)
propertyCount++;
else if((!fields[i].isProperty) && showFields)
fieldCount++;
}
// If there is nothing to display, show message.
if(showFields && showProperties && fieldCount == 0 && propertyCount == 0)
GUILayout.Label("This type has no serializable fields or properties.");
else if(showFields && fieldCount == 0)
GUILayout.Label("This type has no serializable fields.");
else if(showProperties && propertyCount == 0)
GUILayout.Label("This type has no serializable properties.");
// Display Select All/Select None buttons only if there are fields to display.
if(fieldCount > 0 || propertyCount > 0)
{
EditorGUILayout.BeginHorizontal();
if(GUILayout.Button("Select All", selectAllNoneButtonStyle))
{
SelectAll(showFields, showProperties);
Generate();
}
if(GUILayout.Button("Select None", selectAllNoneButtonStyle))
{
SelectNone(showFields, showProperties);
Generate();
}
EditorGUILayout.EndHorizontal();
}
for(int i=0; i<fields.Length; i++)
{
var field = fields[i];
if((field.isProperty && !showProperties) || ((!field.isProperty) && !showFields))
continue;
EditorGUILayout.BeginHorizontal();
var content = new GUIContent(field.Name);
if(typeof(UnityEngine.Object).IsAssignableFrom(field.MemberType))
content.tooltip = field.MemberType.ToString() + "\nSaved by reference";
else
content.tooltip = field.MemberType.ToString() + "\nSaved by value";
bool selected = EditorGUILayout.ToggleLeft(content, fieldSelected[i]);
if(selected != fieldSelected[i])
{
fieldSelected[i] = selected;
unsavedChanges = true;
}
EditorGUILayout.EndHorizontal();
}
}
// Selects all fields, properties or both.
private void SelectAll(bool selectFields, bool selectProperties)
{
for(int i=0; i<fieldSelected.Length; i++)
if((fields[i].isProperty && selectProperties) || (!fields[i].isProperty) && selectFields)
fieldSelected[i] = true;
}
// Selects all fields, properties or both.
private void SelectNone(bool selectFields, bool selectProperties)
{
for(int i=0; i<fieldSelected.Length; i++)
if((fields[i].isProperty && selectProperties) || (!fields[i].isProperty) && selectFields)
fieldSelected[i] = false;
}
public override void OnLostFocus()
{
if(unsavedChanges)
Generate();
}
private void TypeButton(int i)
{
var type = types[i];
if(!types[i].showInList)
return;
if(type.hasExplicitES3Type)
EditorGUILayout.BeginHorizontal();
var thisTypeButtonStyle = (i == selectedType) ? selectedTypeButtonStyle : typeButtonStyle;
if(GUILayout.Button(new GUIContent(type.name, type.namespaceName), thisTypeButtonStyle))
SelectType(i);
// Set the cursor.
var buttonRect = GUILayoutUtility.GetLastRect();
EditorGUIUtility.AddCursorRect(buttonRect, MouseCursor.Link);
if(type.hasExplicitES3Type)
{
GUILayout.Box(new GUIContent(checkmark, "Type is explicitly supported"), EditorStyles.largeLabel);
EditorGUILayout.EndHorizontal();
}
}
private void PerformSearch(string query)
{
var lowerCaseQuery = query.ToLowerInvariant();
var emptyQuery = string.IsNullOrEmpty(query);
for(int i=0; i<types.Length; i++)
types[i].showInList = (emptyQuery || types[i].lowercaseName.Contains(lowerCaseQuery));
}
public void SelectType(Type type)
{
Init();
for (int i = 0; i < types.Length; i++)
if (types[i].type == type)
SelectType(i);
}
private void SelectType(int typeIndex)
{
selectedType = typeIndex;
if(selectedType == -1)
{
SaveType("TypesWindowSelectedType", -1);
return;
}
SaveType("TypesWindowSelectedType", selectedType);
if(!recentTypes.Contains(typeIndex))
{
// If our recent type queue is full, remove an item before adding another.
if(recentTypes.Count == recentTypeCount)
recentTypes.RemoveAt(0);
recentTypes.Add(typeIndex);
for(int j=0; j<recentTypes.Count; j++)
SaveType("TypesWindowRecentType"+j, recentTypes[j]);
}
var type = types[selectedType].type;
fields = ES3Reflection.GetSerializableMembers(type, false);
fieldSelected = new bool[fields.Length];
var es3Type = ES3TypeMgr.GetES3Type(type);
// If there's no ES3Type for this, only select fields which are supported by reflection.
if(es3Type == null)
{
var safeFields = ES3Reflection.GetSerializableMembers(type, true);
for(int i=0; i<fields.Length; i++)
fieldSelected[i] = safeFields.Any(item => item.Name == fields[i].Name);
return;
}
// Get fields and whether they're selected.
var selectedFields = new List<string>();
var propertyAttributes = es3Type.GetType().GetCustomAttributes(typeof(ES3PropertiesAttribute), false);
if(propertyAttributes.Length > 0)
selectedFields.AddRange(((ES3PropertiesAttribute)propertyAttributes[0]).members);
fieldSelected = new bool[fields.Length];
for(int i=0; i<fields.Length; i++)
fieldSelected[i] = selectedFields.Contains(fields[i].Name);
}
private void SaveType(string key, int typeIndex)
{
if(typeIndex == -1)
return;
SaveType(key, types[typeIndex].type);
}
private void SaveType(string key, Type type)
{
EditorPrefs.SetString(key, type.AssemblyQualifiedName);
}
private int LoadTypeIndex(string key)
{
string selectedTypeName = EditorPrefs.GetString(key, "");
if(selectedTypeName != "")
{
var type = ES3Reflection.GetType(selectedTypeName);
if(type != null)
{
int typeIndex = GetTypeIndex(type);
if(typeIndex != -1)
return typeIndex;
}
}
return -1;
}
private int GetTypeIndex(Type type)
{
for(int i=0; i<types.Length; i++)
if(types[i].type == type)
return i;
return -1;
}
private void Init()
{
componentTemplateFile = "ES3ComponentTypeTemplate.txt";
classTemplateFile = "ES3ClassTypeTemplate.txt";
valueTemplateFile = "ES3ValueTypeTemplate.txt";
scriptableObjectTemplateFile = "ES3ScriptableObjectTypeTemplate.txt";
// Init Type List
var tempTypes = new List<TypeListItem> ();
var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(assembly => !assembly.FullName.Contains("Editor") && assembly.FullName != "ES3" && !assembly.FullName.Contains("ES3")).OrderBy(assembly => assembly.GetName().Name).ToArray();
foreach (var assembly in assemblies)
{
var assemblyTypes = assembly.GetTypes();
for(int i = 0; i < assemblyTypes.Length; i++)
{
var type = assemblyTypes [i];
if(type.IsGenericType || type.IsEnum || type.IsNotPublic || type.IsAbstract || type.IsInterface)
continue;
var typeName = type.Name;
if(typeName [0] == '$' || typeName [0] == '_' || typeName [0] == '<')
continue;
var typeNamespace = type.Namespace;
var namespaceName = typeNamespace == null ? "" : typeNamespace.ToString();
tempTypes.Add(new TypeListItem (type.Name, namespaceName, type, true, HasExplicitES3Type(type)));
}
}
types = tempTypes.OrderBy(type => type.name).ToArray();
// Load types and recent types.
if (recentTypes == null)
{
recentTypes = new List<int>();
for (int i = 0; i < recentTypeCount; i++)
{
int typeIndex = LoadTypeIndex("TypesWindowRecentType" + i);
if (typeIndex != -1)
recentTypes.Add(typeIndex);
}
SelectType(LoadTypeIndex("TypesWindowSelectedType"));
}
PerformSearch(searchFieldValue);
// Init Assets.
string es3FolderPath = ES3Settings.PathToEasySaveFolder();
checkmark = AssetDatabase.LoadAssetAtPath<Texture2D>(es3FolderPath + "Editor/checkmark.png");
//checkmarkSmall = AssetDatabase.LoadAssetAtPath<Texture2D>(es3FolderPath + "Editor/checkmarkSmall.png");
// Init Styles.
searchBarCancelButtonStyle = new GUIStyle(EditorStyles.miniButton);
var cancelButtonSize = EditorStyles.miniTextField.CalcHeight(new GUIContent(""), 20);
searchBarCancelButtonStyle.fixedWidth = cancelButtonSize;
searchBarCancelButtonStyle.fixedHeight = cancelButtonSize;
searchBarCancelButtonStyle.fontSize = 8;
searchBarCancelButtonStyle.padding = new RectOffset();
searchBarStyle = new GUIStyle(EditorStyles.toolbarTextField);
searchBarStyle.stretchWidth = true;
typeButtonStyle = new GUIStyle(EditorStyles.largeLabel);
typeButtonStyle.alignment = TextAnchor.MiddleLeft;
typeButtonStyle.stretchWidth = false;
selectedTypeButtonStyle = new GUIStyle(typeButtonStyle);
selectedTypeButtonStyle.fontStyle = FontStyle.Bold;
leftPaneStyle = new GUIStyle();
leftPaneStyle.fixedWidth = leftPaneWidth;
leftPaneStyle.clipping = TextClipping.Clip;
leftPaneStyle.padding = new RectOffset(10, 10, 10, 10);
selectAllNoneButtonStyle = new GUIStyle(EditorStyles.miniButton);
selectAllNoneButtonStyle.stretchWidth = false;
selectAllNoneButtonStyle.margin = new RectOffset(0,0,0,10);
}
private void Generate()
{
var type = types[selectedType].type;
if(type == null)
{
EditorUtility.DisplayDialog("Type not selected", "Type not selected. Please ensure you select a type", "Ok");
return;
}
unsavedChanges = false;
// Get the serializable fields of this class.
//var fields = ES3Reflection.GetSerializableES3Fields(type);
// The string that we suffix to the class name. i.e. UnityEngine_UnityEngine_Transform.
string es3TypeSuffix = type.Name;
// The string for the full C#-safe type name. This name must be suitable for going inside typeof().
string fullType = GetFullTypeName(type);
// The list of WriteProperty calls to write the properties of this type.
string writes = GenerateWrites();
// The list of case statements and Read calls to read the properties of this type.
string reads = GenerateReads();
// A comma-seperated string of fields we've supported in this type.
string propertyNames = "";
bool first = true;
for(int i=0; i<fields.Length; i++)
{
if(!fieldSelected[i])
continue;
if(first)
first = false;
else
propertyNames += ", ";
propertyNames += "\"" + fields[i].Name + "\"";
}
var easySaveEditorPath = ES3Settings.PathToEasySaveFolder()+"Editor/";
// Insert the relevant strings into the template.
string template;
if(typeof(Component).IsAssignableFrom(type))
template = File.ReadAllText(easySaveEditorPath + componentTemplateFile);
else if(ES3Reflection.IsValueType(type))
template = File.ReadAllText(easySaveEditorPath + valueTemplateFile);
else if(typeof(ScriptableObject).IsAssignableFrom(type))
template = File.ReadAllText(easySaveEditorPath + scriptableObjectTemplateFile);
else
template = File.ReadAllText(easySaveEditorPath + classTemplateFile);
template = template.Replace("[es3TypeSuffix]", es3TypeSuffix);
template = template.Replace("[writes]", writes);
template = template.Replace("[reads]", reads);
template = template.Replace("[propertyNames]", propertyNames);
template = template.Replace("[fullType]", fullType); // Do this last as we use the [fullType] tag in reads.
// Create the output file.
string outputFilePath = GetOutputPath(type);
var fileInfo = new FileInfo(outputFilePath);
fileInfo.Directory.Create();
File.WriteAllText(outputFilePath, template);
AssetDatabase.Refresh();
}
private string GenerateWrites()
{
var type = types[selectedType].type;
bool isComponent = typeof(Component).IsAssignableFrom(type);
string writes = "";
for(int i=0; i<fields.Length; i++)
{
var field = fields[i];
var selected = fieldSelected[i];
var es3Type = ES3TypeMgr.GetES3Type(field.MemberType);
if(!selected || isComponent && (field.Name == ES3Reflection.componentTagFieldName || field.Name == ES3Reflection.componentNameFieldName))
continue;
string writeByRef = ES3Reflection.IsAssignableFrom(typeof(UnityEngine.Object), field.MemberType) ? "ByRef" : "";
string es3TypeParam = HasExplicitES3Type(es3Type) && writeByRef == "" && !field.MemberType.IsEnum ? ", " + es3Type.GetType().Name + ".Instance" : (writeByRef == "" ? ", ES3Internal.ES3TypeMgr.GetOrCreateES3Type(typeof(" + GetFullTypeName(field.MemberType) + "))" : "");
// If this is static, access the field through the class name rather than through an instance.
string instance = (field.IsStatic) ? GetFullTypeName(type) : "instance";
if(!field.IsPublic)
{
string memberType = field.isProperty ? "Property" : "Field";
writes += String.Format("\r\n\t\t\twriter.WritePrivate{2}{1}(\"{0}\", instance);", field.Name, writeByRef, memberType);
}
else
writes += String.Format("\r\n\t\t\twriter.WriteProperty{1}(\"{0}\", {3}.{0}{2});", field.Name, writeByRef, es3TypeParam, instance);
}
return writes;
}
private string GenerateReads()
{
var type = types[selectedType].type;
bool isComponent = typeof(Component).IsAssignableFrom(type);
string reads = "";
for(int i=0; i<fields.Length; i++)
{
var field = fields[i];
var selected = fieldSelected[i];
if(!selected || isComponent && (field.Name == "tag" || field.Name == "name"))
continue;
string fieldTypeName = GetFullTypeName(field.MemberType);
string es3TypeParam = HasExplicitES3Type(field.MemberType) ? ES3TypeMgr.GetES3Type(field.MemberType).GetType().Name+".Instance" : "";
// If this is static, access the field through the class name rather than through an instance.
string instance = (field.IsStatic) ? GetFullTypeName(type) : "instance";
// If we're writing a private field or property, we need to write it using a different method.
if(!field.IsPublic)
{
es3TypeParam = ", " + es3TypeParam;
if(field.isProperty)
reads += String.Format("\r\n\t\t\t\t\tcase \"{0}\":\r\n\t\t\t\t\tinstance = ([fullType])reader.SetPrivateProperty(\"{0}\", reader.Read<{1}>(), instance);\r\n\t\t\t\t\tbreak;", field.Name, fieldTypeName);
else
reads += String.Format("\r\n\t\t\t\t\tcase \"{0}\":\r\n\t\t\t\t\tinstance = ([fullType])reader.SetPrivateField(\"{0}\", reader.Read<{1}>(), instance);\r\n\t\t\t\t\tbreak;", field.Name, fieldTypeName);
}
else
reads += String.Format("\r\n\t\t\t\t\tcase \"{0}\":\r\n\t\t\t\t\t\t{3}.{0} = reader.Read<{1}>({2});\r\n\t\t\t\t\t\tbreak;", field.Name, fieldTypeName, es3TypeParam, instance);
}
return reads;
}
private string GetOutputPath(Type type)
{
return Application.dataPath + "/Easy Save 3/Types/ES3UserType_"+type.Name+".cs";
}
/* Gets the full Type name, replacing any syntax (such as '+') with a dot to make it a valid type name */
private static string GetFullTypeName(Type type)
{
string typeName = type.ToString();
typeName = typeName.Replace('+','.');
// If it's a generic type, replace syntax with angled brackets.
int genericArgumentCount = type.GetGenericArguments().Length;
if(genericArgumentCount > 0)
{
return string.Format("{0}<{1}>", type.ToString().Split('`')[0], string.Join(", ", type.GetGenericArguments().Select(x => GetFullTypeName(x)).ToArray()));
}
return typeName;
}
/* Whether this type has an explicit ES3Type. For example, ES3ArrayType would return false, but ES3Vector3ArrayType would return true */
private static bool HasExplicitES3Type(Type type)
{
var es3Type = ES3TypeMgr.GetES3Type(type);
if(es3Type == null)
return false;
// If this ES3Type has a static Instance property, return true.
if(es3Type.GetType().GetField("Instance", BindingFlags.Public | BindingFlags.Static) != null)
return true;
return false;
}
private static bool HasExplicitES3Type(ES3Type es3Type)
{
if(es3Type == null)
return false;
// If this ES3Type has a static Instance property, return true.
if(es3Type.GetType().GetField("Instance", BindingFlags.Public | BindingFlags.Static) != null)
return true;
return false;
}
public class TypeListItem
{
public string name;
public string lowercaseName;
public string namespaceName;
public Type type;
public bool showInList;
public bool hasExplicitES3Type;
public TypeListItem(string name, string namespaceName, Type type, bool showInList, bool hasExplicitES3Type)
{
this.name = name;
this.lowercaseName = name.ToLowerInvariant();
this.namespaceName = namespaceName;
this.type = type;
this.showInList = showInList;
this.hasExplicitES3Type = hasExplicitES3Type;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 600b987de172f4a82b182077ceb7fffa
timeCreated: 1519132286
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

View File

@@ -0,0 +1,124 @@
fileFormatVersion: 2
guid: 9d92f481545af4a45b06e8fe44778d93
timeCreated: 1484046036
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: iPhone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: tvOS
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Tizen
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Samsung TV
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

View File

@@ -0,0 +1,124 @@
fileFormatVersion: 2
guid: ca44f6eb870d244cfb1c83054a69ffc3
timeCreated: 1484046036
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: iPhone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: tvOS
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Tizen
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Samsung TV
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1,104 @@
fileFormatVersion: 2
guid: 3ae63f85ae558634d83caaf5a332d1ba
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 B

View File

@@ -0,0 +1,124 @@
fileFormatVersion: 2
guid: 4697547d67ec24040b678d7b35835286
timeCreated: 1495455081
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: iPhone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: tvOS
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Tizen
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Samsung TV
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant: