Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/snpm/safehandles
Unity Handles that can be used from anywhere.
https://github.com/snpm/safehandles
Last synced: about 2 months ago
JSON representation
Unity Handles that can be used from anywhere.
- Host: GitHub
- URL: https://github.com/snpm/safehandles
- Owner: SnpM
- License: mit
- Created: 2015-10-21T04:11:33.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-21T05:43:04.000Z (about 9 years ago)
- Last Synced: 2024-08-03T05:18:09.970Z (5 months ago)
- Language: C#
- Size: 141 KB
- Stars: 6
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SafeHandles
Unity Handles that can be used from anywhere.Example Usage:
```
//In Assets
public class VisualizeAttribute {}
public class Test : MonoBehaviour () {
[Visualize]
public Vector3 inSceneVector3; //Editable in scene
}//In Editor
using UnityEditor;
using UnityEngine;
using SafeHandles;
[CustomPropertyDrawer (typeof (VisualizeAttribute))]
public class EditorVisualize : PropertyDrawer {
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
switch (property.propertyType) {
case SerializedPropertyType.Vector3:
property.vector3Value = EditorGUILayout.Vector3Field(label, property.vector3Value);
property.vector3Value = HandlesHelper.PositionHandle (property.propertyPath, property.vector3Value, Quaternion.identity);
property.serializedObject.ApplyModifiedProperties();
break;
default:
throw new System.ArgumentException(string.Format("The visualization behavior of Type {0} is not implemented", property.propertyType));
break;
}
}
}
```Note: Under development.