public static bool ValidateProfileField_Layout(SerializedProperty property, RagdollDefinition definition, bool isRequired) { string type = ReflectionUtility.GetField(property.serializedObject.targetObject, property.name).FieldType.Name; if (!property.objectReferenceValue) { if (isRequired) { NaughtyEditorGUI.HelpBox_Layout($"A {type} is required.", MessageType.Error); return(false); } else { return(true); } } else if (!(property.objectReferenceValue as RagdollProfile).IsValid) { NaughtyEditorGUI.HelpBox_Layout($"The assigned {type} is not valid.", MessageType.Error); return(false); } else if (definition != null && (property.objectReferenceValue as RagdollProfile).IsCompatibleWith(definition) != definition) { NaughtyEditorGUI.HelpBox_Layout($"The bound RagdollDefinition and the {type}'s RagdollDefinition are incompatible.", MessageType.Error); return(false); } else { return(true); } }
public static void Draw(Rect rect, SerializedProperty property, RagdollDefinition definition, GUIContent guiContent) { GUIContent label = EditorGUI.BeginProperty(rect, guiContent, property); property.stringValue = Draw(rect, property.stringValue, label, definition); EditorGUI.EndProperty(); }
public static bool IsValidValue(string value, RagdollDefinition ragdollDefinition) { foreach (BoneName bone in ragdollDefinition.Bones) { if (value == bone) return true; } return false; }
public override bool IsCompatibleWith(RagdollDefinition otherDefinition) { if (!definition) { return(true); } else { return(base.IsCompatibleWith(otherDefinition)); } }
static string[] GetOptionsFromDefinition(RagdollDefinition definition) { IEnumerable boneNames = definition.Bones; string[] names = new string[definition.BoneCount]; int i = 0; foreach (BoneName name in boneNames) { names[i] = name; i++; } return names; }
public static void SetCurrentRagdollDefinition(RagdollDefinition definition) { currentDefinition = definition; }
public static string Draw(Rect rect, string currentValue, GUIContent guiContent, RagdollDefinition definition) { string[] options = GetOptionsFromDefinition(definition); int selectedIndex = System.Array.IndexOf(options, currentValue); rect.height = EditorGUIUtility.singleLineHeight; int newSelection = EditorGUI.Popup(rect, guiContent.text, selectedIndex, options); if (newSelection == -1) { ShowBoneNotFoundError(currentValue, definition.name); return currentValue; } else { return options[newSelection]; } }
public static void Draw(Rect rect, SerializedProperty property, RagdollDefinition definition) { Draw(rect, property, definition, property.GetLabelContent()); }
public static string Draw_Layout(string currentValue, GUIContent guiContent, RagdollDefinition definition) { return Draw(EditorGUILayout.GetControlRect(), currentValue, guiContent, definition); }
public static void Draw_Layout(SerializedProperty property, GUIContent guiContent, RagdollDefinition definition) { Rect rect = EditorGUILayout.GetControlRect(); GUIContent label = EditorGUI.BeginProperty(rect, guiContent, property); property.stringValue = Draw(rect, property.stringValue, label, definition); EditorGUI.EndProperty(); }
public static void Draw_Layout(SerializedProperty property, RagdollDefinition definition) { Draw_Layout(property, property.GetLabelContent(), definition); }