From f6b69c72b5f186bcb7cd5c60a67394b9c41db6db Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Wed, 3 Jun 2015 23:26:30 +0600 Subject: [PATCH] save for editor properties --- Assets/IsoTools/Editor/IsoEditorWindow.cs | 22 +++++++ Assets/IsoTools/Examples/Scenes/Scene5.unity | 14 ++--- .../Examples/Scripts/IsoController.cs | 62 +++++++++---------- UnityIso.userprefs | 6 +- 4 files changed, 62 insertions(+), 42 deletions(-) diff --git a/Assets/IsoTools/Editor/IsoEditorWindow.cs b/Assets/IsoTools/Editor/IsoEditorWindow.cs index 133f7c2..c35347f 100644 --- a/Assets/IsoTools/Editor/IsoEditorWindow.cs +++ b/Assets/IsoTools/Editor/IsoEditorWindow.cs @@ -8,6 +8,9 @@ namespace IsoTools { public static bool Alignment { get; private set; } public static bool ShowBounds { get; private set; } + static string _alignmentPropName = "IsoTools.IsoEditorWindow.Alignment"; + static string _showBoundsPropName = "IsoTools.IsoEditorWindow.ShowBounds"; + void AlignmentSelection() { var iso_objects = Selection.gameObjects .Where(p => p.GetComponent()) @@ -33,5 +36,24 @@ namespace IsoTools { AlignmentSelection(); } } + + void OnFocus() { + if ( EditorPrefs.HasKey(_alignmentPropName) ) { + Alignment = EditorPrefs.GetBool(_alignmentPropName); + } + if ( EditorPrefs.HasKey(_showBoundsPropName) ) { + ShowBounds = EditorPrefs.GetBool(_showBoundsPropName); + } + } + + void OnLostFocus() { + EditorPrefs.SetBool(_alignmentPropName, Alignment); + EditorPrefs.SetBool(_showBoundsPropName, ShowBounds); + } + + void OnDestroy() { + EditorPrefs.SetBool(_alignmentPropName, Alignment); + EditorPrefs.SetBool(_showBoundsPropName, ShowBounds); + } } } \ No newline at end of file diff --git a/Assets/IsoTools/Examples/Scenes/Scene5.unity b/Assets/IsoTools/Examples/Scenes/Scene5.unity index 82c96ba..27f7bda 100644 --- a/Assets/IsoTools/Examples/Scenes/Scene5.unity +++ b/Assets/IsoTools/Examples/Scenes/Scene5.unity @@ -104,7 +104,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalPosition.z - value: 44.4444427 + value: 37.5 objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalRotation.x @@ -308,7 +308,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} propertyPath: m_LocalPosition.z - value: 88.8888931 + value: 87.5 objectReference: {fileID: 0} - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} propertyPath: m_LocalRotation.x @@ -390,7 +390,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} propertyPath: m_LocalPosition.z - value: 77.7777786 + value: 75 objectReference: {fileID: 0} - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} propertyPath: m_LocalRotation.x @@ -472,7 +472,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} propertyPath: m_LocalPosition.z - value: 66.6666641 + value: 62.5 objectReference: {fileID: 0} - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} propertyPath: m_LocalRotation.x @@ -550,7 +550,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalPosition.z - value: 55.5555534 + value: 50 objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalRotation.x @@ -738,7 +738,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalPosition.z - value: 33.3333321 + value: 25 objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalRotation.x @@ -1020,7 +1020,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} propertyPath: m_LocalPosition.z - value: 11.1111107 + value: 12.5 objectReference: {fileID: 0} - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} propertyPath: m_LocalRotation.x diff --git a/Assets/IsoTools/Examples/Scripts/IsoController.cs b/Assets/IsoTools/Examples/Scripts/IsoController.cs index 0899352..956c141 100644 --- a/Assets/IsoTools/Examples/Scripts/IsoController.cs +++ b/Assets/IsoTools/Examples/Scripts/IsoController.cs @@ -1,39 +1,37 @@ using UnityEngine; using System.Collections; -namespace IsoTools { - namespace Examples { - public class IsoController : MonoBehaviour { - void MoveIsoObject(Vector3 dir) { - var iso_object = GetComponent(); - var iso_rigidbody = GetComponent(); - if ( iso_rigidbody ) { - iso_rigidbody.Rigidbody.velocity = dir; - } - else if ( iso_object ) { - iso_object.Position += dir * Time.deltaTime; - } +namespace IsoTools { namespace Examples { + public class IsoController : MonoBehaviour { + void MoveIsoObject(Vector3 dir) { + var iso_object = GetComponent(); + var iso_rigidbody = GetComponent(); + if ( iso_rigidbody ) { + iso_rigidbody.Rigidbody.velocity = dir; } - void Update () { - if ( Input.GetKey(KeyCode.LeftArrow) ) { - MoveIsoObject(new Vector3(-1, 0, 0)); - } - if ( Input.GetKey(KeyCode.RightArrow) ) { - MoveIsoObject(new Vector3(1, 0, 0)); - } - if ( Input.GetKey(KeyCode.DownArrow) ) { - MoveIsoObject(new Vector3(0, -1, 0)); - } - if ( Input.GetKey(KeyCode.UpArrow) ) { - MoveIsoObject(new Vector3(0, 1, 0)); - } - if ( Input.GetKey(KeyCode.A) ) { - MoveIsoObject(new Vector3(0, 0, 1)); - } - if ( Input.GetKey(KeyCode.Z) ) { - MoveIsoObject(new Vector3(0, 0, -1)); - } + else if ( iso_object ) { + iso_object.Position += dir * Time.deltaTime; + } + } + void Update () { + if ( Input.GetKey(KeyCode.LeftArrow) ) { + MoveIsoObject(new Vector3(-1, 0, 0)); + } + if ( Input.GetKey(KeyCode.RightArrow) ) { + MoveIsoObject(new Vector3(1, 0, 0)); + } + if ( Input.GetKey(KeyCode.DownArrow) ) { + MoveIsoObject(new Vector3(0, -1, 0)); + } + if ( Input.GetKey(KeyCode.UpArrow) ) { + MoveIsoObject(new Vector3(0, 1, 0)); + } + if ( Input.GetKey(KeyCode.A) ) { + MoveIsoObject(new Vector3(0, 0, 1)); + } + if ( Input.GetKey(KeyCode.Z) ) { + MoveIsoObject(new Vector3(0, 0, -1)); } } } -} \ No newline at end of file +}} // namespace IsoTools::Examples \ No newline at end of file diff --git a/UnityIso.userprefs b/UnityIso.userprefs index a1d943a..331445f 100644 --- a/UnityIso.userprefs +++ b/UnityIso.userprefs @@ -1,9 +1,9 @@  - + - - + +