void ConstraintToggle(Rect r, string label, RigidbodyConstraints value, int bit) { bool toggle = ((int)value & (1 << bit)) != 0; EditorGUI.showMixedValue = (m_Constraints.hasMultipleDifferentValuesBitwise & (1 << bit)) != 0; EditorGUI.BeginChangeCheck(); int oldIndent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; toggle = EditorGUI.ToggleLeft(r, label, toggle); EditorGUI.indentLevel = oldIndent; if (EditorGUI.EndChangeCheck()) { Undo.RecordObjects(targets, "Edit Constraints"); m_Constraints.SetBitAtIndexForAllTargetsImmediate(bit, toggle); } EditorGUI.showMixedValue = false; }
internal static bool BitToggleField(string label, SerializedProperty bitFieldProperty, int flag) { bool flag2 = (bitFieldProperty.intValue & flag) != 0; bool flag3 = (bitFieldProperty.hasMultipleDifferentValuesBitwise & flag) != 0; EditorGUI.showMixedValue = flag3; EditorGUI.BeginChangeCheck(); flag2 = EditorGUILayout.Toggle(label, flag2, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { if (flag3) { flag2 = true; } flag3 = false; int index = -1; for (int i = 0; i < 32; i++) { if ((1 << i & flag) != 0) { index = i; break; } } bitFieldProperty.SetBitAtIndexForAllTargetsImmediate(index, flag2); } EditorGUI.showMixedValue = false; return flag2 && !flag3; }
internal static bool BitToggleField(string label, SerializedProperty bitFieldProperty, int flag) { bool flag1 = (bitFieldProperty.intValue & flag) != 0; bool flag2 = (bitFieldProperty.hasMultipleDifferentValuesBitwise & flag) != 0; EditorGUI.showMixedValue = flag2; EditorGUI.BeginChangeCheck(); bool flag3 = EditorGUILayout.Toggle(label, flag1, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { if (flag2) flag3 = true; flag2 = false; int index1 = -1; for (int index2 = 0; index2 < 32; ++index2) { if ((1 << index2 & flag) != 0) { index1 = index2; break; } } bitFieldProperty.SetBitAtIndexForAllTargetsImmediate(index1, flag3); } EditorGUI.showMixedValue = false; if (flag3) return !flag2; return false; }