public static string DrawCopyPasteButtonArray(Rect p_position, SerializedProperty p_property) { string _click = ""; p_position.width = p_position.width / 2; if (GUI.Button(p_position, "Copy All")) { CopyPasteAttribute.sourceSerializedProperty = p_property; // // string _type = CopyPasteAttribute.sourceSerializedProperty.GetType().Name; // Debug.Log(p_property.arraySize); // if(_type == "Object[]"){ CopyPasteAttribute.sourceSerializedProperty = p_property; CopyPasteAttribute.propertyObj = p_property.serializedObject.targetObject; CopyPasteAttribute.propertyPath = p_property.propertyPath; // }else{ // CopyPasteAttribute.propertyObj = null; // CopyPasteAttribute.propertyPath = ""; // } CopyPasteAttribute.isArray = true; _click = "Copy"; } p_position.x += p_position.width; if ((CopyPasteAttribute.sourceSerializedProperty != null) && (CopyPasteAttribute.isArray)) { if (GUI.Button(p_position, "Paste All")) { if (CopyPasteAttribute.propertyObj != null) { CopyPasteAttribute.sourceSerializedProperty = GetSerializedProperty(CopyPasteAttribute.propertyObj, CopyPasteAttribute.propertyPath); } SerializedPropertyValue.SetValue( p_property, SerializedPropertyValue.GetValue( CopyPasteAttribute.sourceSerializedProperty ) ); _click = "Paste"; } } else { GUI.enabled = false; GUI.Button(p_position, "Paste All"); GUI.enabled = true; } return(_click); }
public override void OnGUI(Rect p_position, SerializedProperty p_property, GUIContent p_Label) { object _obj = SerializedPropertyValue.GetValue(p_property); LessAlarmAttribute _Alarm = attribute as LessAlarmAttribute; if (SerializedPropertyValue.isNumber(p_property)) { float _number; if (p_property.propertyType == SerializedPropertyType.Float) { _number = (float)_obj; } else { _number = (int)_obj; } if (_number < _Alarm.floatTarget) { GUI.color = Color.red; if (_Alarm.floatNow != _number) { MonoBehaviour _Mono = (MonoBehaviour)p_property.serializedObject.targetObject; if (_Alarm.log) { Debug.LogWarning("Attribute Alarm: " + _Mono.name + " / " + p_property.name + " = " + _number + " , Less: " + _Alarm.floatTarget); } if (_Alarm.pause) { Debug.Break(); } } } _Alarm.floatNow = _number; EditorGUI.PropertyField(p_position, p_property, p_Label); GUI.color = Color.white; } else { EditorGUI.LabelField(p_position, p_Label.text, "[LessAlarm] Only for Number"); } }