private void init(SerializedProperty groupProperty) { Assert.IsNotNull(groupProperty); _groupProperty = groupProperty; _multiFeatureList = _groupProperty.FindPropertyRelative("_features"); _multiRenderingMethod = _groupProperty.FindPropertyRelative("_renderingMethod"); _featureTable = MultiTypedListUtil.GetTableProperty(_multiFeatureList); Assert.IsNotNull(_featureTable); if (_featureList == null || !SerializedProperty.EqualContents(_featureList.serializedProperty, _featureTable)) { _featureList = new ReorderableList(_serializedObject, _featureTable, draggable: true, displayHeader: false, displayAddButton: false, displayRemoveButton: false); _featureList.showDefaultBackground = false; _featureList.headerHeight = 0; _featureList.elementHeight = EditorGUIUtility.singleLineHeight; _featureList.elementHeightCallback = featureHeightCallback; _featureList.drawElementCallback = drawFeatureCallback; _featureList.onReorderCallback = onReorderFeaturesCallback; } _renderingMethod = MultiTypedReferenceUtil.GetReferenceProperty(_multiRenderingMethod); _supportInfo = _groupProperty.FindPropertyRelative("_supportInfo"); _cachedPropertyList = new List <SerializedProperty>(); _cachedPropertyHeights = new List <float>(); for (int i = 0; i < _featureTable.arraySize; i++) { var idIndex = _featureTable.GetArrayElementAtIndex(i); var referenceProp = MultiTypedListUtil.GetReferenceProperty(_multiFeatureList, idIndex); _cachedPropertyList.Add(referenceProp); //Make sure to add one line for the label _cachedPropertyHeights.Add(EditorGUI.GetPropertyHeight(referenceProp) + EditorGUIUtility.singleLineHeight); } _renderingMethod = MultiTypedReferenceUtil.GetReferenceProperty(_multiRenderingMethod); if (_renderingMethodMonoScript == null) { _renderingMethodMonoScript = AssetDatabase.FindAssets(_renderingMethod.type). Query(). Where(guid => !string.IsNullOrEmpty(guid)). Select(guid => AssetDatabase.GUIDToAssetPath(guid)). Where(path => Path.GetFileNameWithoutExtension(path) == _renderingMethod.type). Select(path => AssetDatabase.LoadAssetAtPath <MonoScript>(path)). FirstOrDefault(); } }
protected override void OnEnable() { base.OnEnable(); hideField("_anchor"); hideField("_featureData"); hideField("_attachedRenderer"); hideField("_attachedGroupIndex"); hideField("_preferredRendererType"); _featureList = serializedObject.FindProperty("_featureData"); _featureTable = MultiTypedListUtil.GetTableProperty(_featureList); dontShowScriptField(); }
protected void drawFeatureData(LeapGraphicGroup sharedGroup) { using (new ProfilerSample("Draw Leap Gui Graphic Editor")) { if (targets.Length == 0) { return; } var mainGraphic = targets[0]; if (mainGraphic.featureData.Count == 0) { return; } if (mainGraphic.attachedGroup != null) { SpriteAtlasUtil.ShowInvalidSpriteWarning(mainGraphic.attachedGroup.features); } int maxGraphics = LeapGraphicPreferences.graphicMax; if (targets.Query().Any(e => e.attachedGroup != null && e.attachedGroup.graphics.IndexOf(e) >= maxGraphics)) { string noun = targets.Length == 1 ? "This graphic" : "Some of these graphics"; string rendererName = targets.Length == 1 ? "its renderer" : "their renderers"; EditorGUILayout.HelpBox(noun + " may not be properly displayed because there are too many graphics on " + rendererName + ". " + "Either lower the number of graphics or increase the maximum graphic count by visiting " + "Edit->Preferences.", MessageType.Warning); } //If we are not all attached to the same group we cannot show features if (!targets.Query().Select(g => g.attachedGroup).AllEqual()) { return; } EditorGUILayout.Space(); using (new GUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Feature Data: ", EditorStyles.boldLabel); if (sharedGroup != null) { var meshRendering = sharedGroup.renderingMethod as LeapMesherBase; if (meshRendering != null && meshRendering.IsAtlasDirty && !EditorApplication.isPlaying) { if (GUILayout.Button("Refresh Atlas", GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight))) { meshRendering.RebuildAtlas(new ProgressBar()); sharedGroup.renderer.editor.ScheduleRebuild(); } } } } for (int i = 0; i < _featureTable.arraySize; i++) { var idIndex = _featureTable.GetArrayElementAtIndex(i); var dataProp = MultiTypedListUtil.GetReferenceProperty(_featureList, idIndex); EditorGUILayout.LabelField(LeapGraphicTagAttribute.GetTagName(dataProp.type)); if (mainGraphic.attachedGroup != null) { currentFeature = mainGraphic.attachedGroup.features[i]; } EditorGUI.indentLevel++; EditorGUILayout.PropertyField(dataProp, includeChildren: true); EditorGUI.indentLevel--; currentFeature = null; } serializedObject.ApplyModifiedProperties(); } }