static LSScenePropertyDrawer() { List <Type> drawerTypes = LSEditorUtility.GetFilteredTypes(typeof(LSScenePropertyDrawer)); foreach (Type type in drawerTypes) { LSScenePropertyDrawer drawer = (LSScenePropertyDrawer)Activator.CreateInstance(type); Type targetType = drawer.TargetType; MappedDrawers.Add(targetType, drawer); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { long value = property.longValue; LSEditorUtility.DoubleField( position, label, ref value, ((FixedNumberAttribute)this.attribute).Timescaled ); property.longValue = value; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { SerializedProperty angle = property.FindPropertyRelative("_angle"); SerializedProperty timescaled = property.FindPropertyRelative("_timescaled"); double scale = LSEditorUtility.Scale(timescaled.boolValue); angle.doubleValue = EditorGUILayout.DoubleField(label, angle.doubleValue * scale) / scale; timescaled.boolValue = EditorGUILayout.Toggle("Timescaled", timescaled.boolValue); double angleInRadians = angle.doubleValue * Math.PI / 180d; property.FindPropertyRelative("_cos").longValue = FixedMath.Create(Math.Cos(angleInRadians)); property.FindPropertyRelative("_sin").longValue = FixedMath.Create(Math.Sin(angleInRadians)); }
void OnDrawGizmos() { if (!Application.isPlaying) { return; } Gizmos.color = Color.white; Vector3[] PolyLine; LSBody body = this; Vector3 TargetPosition = ((MonoBehaviour)body).transform.position; //TargetPosition.y += .55f; switch (body.Shape) { case ColliderType.Circle: LSEditorUtility.GizmoCircle(TargetPosition, FixedMath.ToFloat(body.Radius)); break; case ColliderType.AABox: PolyLine = new Vector3[] { TargetPosition, TargetPosition, TargetPosition, TargetPosition }; float halfWidth = FixedMath.ToFloat(body.HalfWidth); float halfHeight = FixedMath.ToFloat(body.HalfHeight); PolyLine [0].x += halfWidth; PolyLine [0].z += halfHeight; PolyLine [1].x += halfWidth; PolyLine [1].z -= halfHeight; PolyLine [2].x -= halfWidth; PolyLine [2].z -= halfHeight; PolyLine [3].x -= halfWidth; PolyLine [3].z += halfHeight; LSEditorUtility.GizmoPolyLine(PolyLine); break; case ColliderType.Polygon: int VertLength = body.Vertices.Length; PolyLine = new Vector3[VertLength]; for (int i = 0; i < VertLength; i++) { PolyLine[i] = body.RealPoints[i].ToVector3(TargetPosition.y); } LSEditorUtility.GizmoPolyLine(PolyLine); break; } }
private static IEnumerable <LSScenePropertyDrawer> GetPropertyDrawers(SerializedProperty p) { Type propertyObjectType = LSEditorUtility.GetPropertyType(p); LSScenePropertyDrawer drawer = LSScenePropertyDrawer.GetDrawer(propertyObjectType); yield return(drawer); IEnumerable <PropertyAttribute> propertyAttributes = LSEditorUtility.GetPropertyAttributes <PropertyAttribute>(p); foreach (PropertyAttribute propertyAttribute in propertyAttributes) { drawer = LSScenePropertyDrawer.GetDrawer(propertyAttribute.GetType()); yield return(drawer); } }