public static object GetRuntimeObject(RuntimeSerializedProperty property, string json) { var hashCode = property.HashCodeForPropertyPath(); if (!RuntimeObjectDict.ContainsKey(hashCode)) { RuntimeObjectDict.Add(hashCode, RuntimeObject.FromJson(json)); } return(RuntimeObjectDict[hashCode]); }
private static int GetPropertyHash(RuntimeSerializedProperty property, List <PropertyAttribute> attributes) { if (property.RuntimeSerializedObject == null || property.RuntimeSerializedObject.Target == null) { return(0); } // For efficiency, ignore indices inside brackets [] in order to make array elements share handlers. int key = property.HashCodeForPropertyPath(); if (attributes != null && attributes.Count > 0) { foreach (var attr in attributes) { key ^= attr.GetHashCode(); } } return(key); }
public static int GetHashCode(RuntimeSerializedProperty runtimeSerializedProperty, object o) { return(runtimeSerializedProperty.HashCodeForPropertyPath() ^ o.GetHashCode()); }
public bool DoProperty(Rect position, RuntimeSerializedProperty property) { if (!runtimeReorderableListDict.ContainsKey(property.PropertyPath)) { return(false); } headerPosition = new Rect(position); headerPosition.height = RuntimeEasyGUI.GetPropertyHeight(property, GUIContent.none, false, null); // Draw the background if (DrawBackgroundCallback != null) { Rect backgroundPosition = new Rect(headerPosition); backgroundPosition.xMin += EasyGUI.Indent; if (property.IsExpanded) { backgroundPosition.yMax += 19; } EditorGUI.DrawRect(backgroundPosition, DrawBackgroundCallback(false, false)); } // Draw header if (HeaderCallback != null) { HeaderCallback(headerPosition); } else { string headerName = string.Format(HeaderStr, property.DisplayName, property.ArraySize, property.HashCodeForPropertyPath()); RuntimeEasyGUI.PropertyField(headerPosition, property, new GUIContent(headerName), false, null); } // Draw the reorderable list for the property if (property.IsExpanded) { EditorGUI.BeginDisabledGroup(!Editable); if (!property.Editable) { EditorGUI.indentLevel++; } EditorGUI.BeginChangeCheck(); var sizePosition = new Rect(headerPosition); sizePosition.yMin = headerPosition.yMax; sizePosition.height = EditorGUIUtility.singleLineHeight; var newArraySize = Mathf.Clamp(EditorGUI.IntField(sizePosition, SizeStr, property.ArraySize), 0, int.MaxValue); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(property.RuntimeSerializedObject.TargetObject, SetArraySizeStr); property.ArraySize = newArraySize; EditorUtility.SetDirty(property.RuntimeSerializedObject.TargetObject); } var listPosition = new Rect(sizePosition); listPosition.xMin += EasyGUI.Indent; listPosition.yMin = sizePosition.yMax; var indentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; runtimeReorderableListDict[property.PropertyPath].DoList(listPosition); EditorGUI.indentLevel = indentLevel; if (!property.Editable) { EditorGUI.indentLevel--; } EditorGUI.EndDisabledGroup(); } return(true); }
private string DoHeader(RuntimeSerializedProperty property, Rect position, string displayName) { displayName = string.IsNullOrEmpty(displayName) ? property.DisplayName : displayName; string headerName = string.Format(HeaderStr, displayName, property.ArraySize, property.HashCodeForPropertyPath()); RuntimeEasyGUI.PropertyField(position, property, new GUIContent(headerName), false, null); return(headerName); }