mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-14 17:09:31 +07:00
save for editor properties
This commit is contained in:
@@ -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<IsoObject>())
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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<IsoObject>();
|
||||
var iso_rigidbody = GetComponent<IsoRigidbody>();
|
||||
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<IsoObject>();
|
||||
var iso_rigidbody = GetComponent<IsoRigidbody>();
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}} // namespace IsoTools::Examples
|
||||
@@ -1,9 +1,9 @@
|
||||
<Properties>
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="MonoDevelop.Default" />
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/IsoTools/Scripts/IsoRigidbody.cs">
|
||||
<Files>
|
||||
<File FileName="Assets/IsoTools/Scripts/IsoRigidbody.cs" Line="22" Column="31" />
|
||||
<File FileName="Assets/IsoTools/Scripts/IsoObject.cs" Line="14" Column="12" />
|
||||
<File FileName="Assets/IsoTools/Scripts/IsoRigidbody.cs" Line="80" Column="52" />
|
||||
<File FileName="Assets/IsoTools/Examples/Scripts/IsoController.cs" Line="14" Column="50" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
|
||||
Reference in New Issue
Block a user