public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { FixedNumberAttribute a = ((FixedNumberAttribute)this.attribute); long orgValue = property.longValue; long value = orgValue; LSEditorUtility.DoubleField( position, label, ref value, a.Timescaled ); if (a.Ranged) { if (value > a.Max) { value = a.Max; } else if (value < a.Min) { value = a.Min; } } if (orgValue != value) { property.longValue = value; } }
private void GenerateFromTypes(Type baseType) { bufferData.Clear(); Type scriptBaseType = _dataAttribute.ScriptBaseType; List <Type> filteredTypes = LSEditorUtility.GetFilteredTypes(scriptBaseType); DataItem[] data = Data as DataItem[]; HashSet <Type> lackingTypes = new HashSet <Type> (filteredTypes); for (int i = 0; i < data.Length; i++) { DataItem item = data[i]; ScriptDataItem scriptItem = item as ScriptDataItem; if (lackingTypes.Remove(scriptItem.Script)) { bufferData.Add(item); } } foreach (Type type in lackingTypes) { DataItem item = (DataItem)Activator.CreateInstance((TargetType)); item.Inject(type); item.Name = (type.Name); bufferData.Add(item); } DataItem[] tempData = (DataItem[])Array.CreateInstance(TargetType, bufferData.Count); bufferData.CopyTo(tempData); Data = tempData; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { VectorRotationAttribute at = this.attribute as VectorRotationAttribute; bool timescaled = at.Timescaled; double scale = LSEditorUtility.Scale(timescaled); SerializedProperty x = property.FindPropertyRelative("x"); SerializedProperty y = property.FindPropertyRelative("y"); double angleInRadians = Math.Atan2(y.longValue.ToDouble(), x.longValue.ToDouble()); double angleInDegrees = (angleInRadians * 180d / Math.PI) * scale; height = 15f; position.height = height; angleInDegrees = (EditorGUI.DoubleField(position, "Angle", angleInDegrees)) / scale; double newAngleInRadians = angleInDegrees * Math.PI / 180d; if (Math.Abs(newAngleInRadians - angleInRadians) >= .001f) { long cos = FixedMath.Create(Math.Cos(newAngleInRadians)); long sin = FixedMath.Create(Math.Sin(newAngleInRadians)); x.longValue = cos; y.longValue = sin; } }
private static void DrawDatabase(DataHelper dataHelper) { dataHelper.serializedObject.Update(); EditorGUI.BeginChangeCheck(); LSEditorUtility.ListField(dataHelper.DataProperty, dataHelper.ListFlags); if (EditorGUI.EndChangeCheck()) { dataHelper.serializedObject.ApplyModifiedProperties(); } GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); //folding all foldAllBufferBuffer = foldAllBuffer; foldAllBuffer = false; if (GUILayout.Button("Fold All", GUILayout.MaxWidth(50))) { FoldAll(); } //Search EditorGUILayout.LabelField("Filter: ", GUILayout.MaxWidth(35)); searchString = EditorGUILayout.TextField(searchString, GUILayout.ExpandWidth(true)); if (GUILayout.Button("X", GUILayout.MaxWidth(20))) { searchString = ""; } if (lastSearchString != searchString) { if (string.IsNullOrEmpty(searchString) == false) { dataHelper.FilterWithString(searchString); } lastSearchString = searchString; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Order Alphabetically")) { dataHelper.Sort((a1, a2) => a1.Name.CompareTo(a2.Name)); } SortInfo[] sorts = dataHelper.Sorts; for (int i = 0; i < sorts.Length; i++) { SortInfo sort = sorts [i]; if (GUILayout.Button(sort.sortName)) { dataHelper.Sort((a1, a2) => sort.degreeGetter(a1) - sort.degreeGetter(a2)); } } EditorGUILayout.EndHorizontal(); dataHelper.Manage(); dataHelper.serializedObject.Update(); EditorGUILayout.Space(); }
public void GenerateEnum() { this.CullDuplicates(); LSEditorUtility.GenerateEnum( this.SourceEditor.MainWindow.DatabaseDirectory + "/", DataCodeName, this ); }
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)); }
public override void OnInspectorGUI() { Type T = target.GetType(); EditorGUI.BeginChangeCheck(); if (T == typeof(Move)) { Move Target = (Move)target; LSEditorUtility.FixedNumberField("Speed", ref Target.Speed); } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } }
private void GenerateFromTypes(Type baseType) { bufferData.Clear(); Type scriptBaseType = _dataAttribute.ScriptBaseType; List <Type> filteredTypes = LSEditorUtility.GetFilteredTypes(scriptBaseType); DataItem[] data = Data as DataItem[]; HashSet <Type> lackingTypes = new HashSet <Type> (); Type abilityType = typeof(Ability); Type activeAbilityType = typeof(ActiveAbility); for (int i = 0; i < filteredTypes.Count; i++) { if (filteredTypes[i].BaseType != abilityType && filteredTypes[i].BaseType != activeAbilityType) { if (filteredTypes[i].GetCustomAttributes(typeof(CustomActiveAbilityAttribute), false).Length == 0) { continue; } } lackingTypes.Add(filteredTypes[i]); } for (int i = 0; i < data.Length; i++) { DataItem item = data[i]; ScriptDataItem scriptItem = item as ScriptDataItem; if (lackingTypes.Remove(scriptItem.Script)) { bufferData.Add(item); } } foreach (Type type in lackingTypes) { DataItem item = (DataItem)Activator.CreateInstance((TargetType)); item.Inject(type); bufferData.Add(item); } DataItem[] tempData = (DataItem[])Array.CreateInstance(TargetType, bufferData.Count); bufferData.CopyTo(tempData); Data = tempData; }
public sealed override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (initialized == false) { Initialize(); } dataItemAttribute = dataItemAttribute ?? (DataItemAttribute)Attribute.GetCustomAttribute(LSEditorUtility.GetPropertyType(property), typeof(DataItemAttribute), false) ?? new DataItemAttribute(); ; Rect pos = position; pos.height = defaultPropertyHeight; serializedProperties.Clear(); float height = defaultPropertyHeight; string saveID = property.propertyPath; SerializedProperty nameProp = property.FindPropertyRelative("_name"); SerializedProperty iterationProperty = nameProp.Copy(); if (EditorLSDatabase.foldAll) { LSEditorUtility.SetPersistentFlag(saveID, false); } if (LSEditorUtility.PersistentFoldout(pos, nameProp.stringValue, saveID )) { pos.y += defaultPropertyHeight; if (dataItemAttribute.WritableName) { serializedProperties.Add(nameProp); } int beginningDepth = iterationProperty.depth; while (iterationProperty.NextVisible(true)) { if (iterationProperty.depth <= beginningDepth - 1) { //serializedProperties.RemoveAt(serializedProperties.Count - 1); break; } if (iterationProperty.depth > beginningDepth) { continue; } serializedProperties.Add(iterationProperty.Copy()); } pos.x += defaultPropertyHeight; pos.width -= defaultPropertyHeight; for (int i = 0; i < serializedProperties.Count; i++) { SerializedProperty curProp = serializedProperties[i]; float propertyHeight = EditorGUI.GetPropertyHeight(curProp, new GUIContent(), true); EditorGUI.PropertyField(pos, curProp, true); pos.y += propertyHeight; height += propertyHeight; } } LSEditorUtility.SetPersistentValue(saveID, height); }
public sealed override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float height = LSEditorUtility.GetPersistentValue(defaultPropertyHeight, property.propertyPath); return(height); }