protected void DrawObjectDetail(UnityEngine.Object obj, Rect rect) { if (obj != null) { serializedObj = ActionGUIUtil.CreateCachedSerializedObject(obj); rect.y += EditorGUIUtility.singleLineHeight + 5; serializedObj.Update(); ActionGUIUtil.DrawChildInContent(serializedObj.GetIterator(), rect, ignoreProps, null, 1); serializedObj.ApplyModifiedProperties(); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { elementNameProp = property.FindPropertyRelative("enviromentName"); guidProp = property.FindPropertyRelative("guid"); instenceIDProp = property.FindPropertyRelative("instenceID"); enviromentNameProp = property.FindPropertyRelative("enviromentName"); coordinateProp = property.FindPropertyRelative("coordinate"); var btnRect = new Rect(position.x, position.y, position.width - ActionGUIUtil.middleButtonWidth, EditorGUIUtility.singleLineHeight); if (instenceIDProp.intValue != 0 && EditorUtility.InstanceIDToObject(instenceIDProp.intValue) == null) { instenceIDProp.intValue = 0; property.isExpanded = false; } if (!string.IsNullOrEmpty(guidProp.stringValue) && string.IsNullOrEmpty(AssetDatabase.GUIDToAssetPath(guidProp.stringValue))) { guidProp.stringValue = null; } if (GUI.Button(btnRect, elementNameProp.stringValue, EditorStyles.toolbarDropDown)) { property.isExpanded = !property.isExpanded; if (property.isExpanded) { ActionEditorUtility.LoadPrefab(guidProp.stringValue, instenceIDProp, coordinateProp); } else { ActionEditorUtility.SavePrefab(instenceIDProp, coordinateProp); } } var objRect = new Rect(position.x + position.width - ActionGUIUtil.middleButtonWidth, position.y, ActionGUIUtil.middleButtonWidth, EditorGUIUtility.singleLineHeight); if (!string.IsNullOrEmpty(guidProp.stringValue)) { if (GUI.Button(objRect, "", EditorStyles.objectFieldMiniThumb)) { GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath(guidProp.stringValue)); EditorGUIUtility.PingObject(prefab); } if (Event.current.type == EventType.DragUpdated && objRect.Contains(Event.current.mousePosition)) { ActionGUIUtil.UpdateDragedObjects <GameObject>(".prefab", dragedGameObjs); } else if (Event.current.type == EventType.DragPerform && objRect.Contains(Event.current.mousePosition)) { foreach (var item in dragedGameObjs) { RecordPrefab(item); break; } } } else { var obj = EditorGUI.ObjectField(objRect, null, typeof(GameObject), false); if (obj != null) { RecordPrefab(obj); } } if (instenceIDProp.intValue != 0) { DrawInfo(position); } if (property.isExpanded) { position.y += EditorGUIUtility.singleLineHeight + 2f; EditorGUI.BeginChangeCheck(); ActionGUIUtil.DrawChildInContent(property, position, null, "ignore", -1); if (EditorGUI.EndChangeCheck()) { if (instenceTranform) { ActionEditorUtility.LoadCoordinatePropInfo(coordinateProp, instenceTranform); } } else { if (instenceTranform) { ActionEditorUtility.SaveCoordinatesInfo(coordinateProp, instenceTranform); } } } }