public override void RefreshMeshData() { var spriteData = this.Sprite(); if (spriteData == null || spriteData.sprite == null) { mesh = null; remappableChannels = 0; return; } var sprite = spriteData.sprite; mesh = new Mesh(); mesh.name = "Sprite Mesh"; mesh.hideFlags = HideFlags.HideAndDontSave; mesh.vertices = sprite.vertices.Query().Select(v => (Vector3)v).ToArray(); mesh.triangles = sprite.triangles.Query().Select(i => (int)i).ToArray(); Vector2[] uvs; if (SpriteAtlasUtil.TryGetAtlasedUvs(sprite, out uvs)) { mesh.uv = uvs; } mesh.RecalculateBounds(); //We are using atlas uvs, so no remapping allowed! remappableChannels = 0; }
protected virtual void extractSpriteRects() { using (new ProfilerSample("Extract Sprite Rects")) { foreach (var spriteFeature in _spriteFeatures) { for (int i = 0; i < spriteFeature.featureData.Count; i++) { var dataObj = spriteFeature.featureData[i]; var sprite = dataObj.sprite; if (sprite == null) { continue; } Rect rect; if (SpriteAtlasUtil.TryGetAtlasedRect(sprite, out rect)) { _atlasUvs.SetRect(spriteFeature.channel.Index(), sprite, rect); } else { _atlasUvs.SetRect(spriteFeature.channel.Index(), sprite, default(Rect)); } } } } }
private void drawSpriteWarning() { var list = Pool <List <LeapGraphicFeatureBase> > .Spawn(); try { foreach (var group in _renderer.groups) { list.AddRange(group.features); } SpriteAtlasUtil.ShowInvalidSpriteWarning(list); } finally { list.Clear(); Pool <List <LeapGraphicFeatureBase> > .Recycle(list); } }
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(); } }