public void Draw(object value, Rect fullRect, bool selected, IconStyle style) { if (!(value is Sprite sprite)) { return; } PvCustomizerGUI.DrawSprite(style.DrawRect, sprite, style.Material, tint: style.Tint); }
public void Draw(object value, Rect fullRect, bool selected, IconStyle style) { if (!(value is Texture2D tex)) { return; } PvCustomizerGUI.DrawTexture(style.DrawRect, tex, style.Material, style.Tint, style.ScaleMode); }
public void Draw(object value, Rect fullRect, bool selected, IconStyle style) { if (!(value is GridSample asset)) { return; } PvCustomizerGUI.DrawBackground(style.DrawRect); PvCustomizerGUI.DrawTexture(style.DrawRect, asset.texture1, style.Material, style.Tint, style.ScaleMode); }
public void Draw(object value, Rect fullRect, bool selected, IconStyle style) { if (!(value is IList <Sprite> sprites)) { return; } Rect drawRect = style.DrawRect; if (sprites.Count == 0) { PvCustomizerGUI.DrawBorder(drawRect, Color.magenta); PvCustomizerGUI.DrawTextDirect(drawRect, "Empty Array", Color.magenta, UnityEngine.FontStyle.Normal, PvAnchor.MiddleCenter); } else { int gridSize = Mathf.CeilToInt(Mathf.Sqrt(sprites.Count)); float width = drawRect.width / gridSize; float height = drawRect.height / gridSize; int nonNull = 0; for (int i = 0; i < sprites.Count; i++) { Sprite sprite = sprites[i]; if (sprite == null) { continue; } nonNull++; PvCustomizerGUI.DrawSprite(new Rect() { x = drawRect.x + width * (i % gridSize), y = drawRect.y + height * (i / gridSize), width = width, height = height }, sprite, style.Material, style.Tint, style.ScaleMode); } if (style.SizeType == IconSizeType.Large) { const int size = 10; using (new TempFontSize(size)) { string label = $"{nonNull}/{sprites.Count}"; GUI.skin.label.CalcMinMaxWidth(new GUIContent(label), out var min, out var max); Rect area = new Rect(drawRect.xMax - min, drawRect.yMax - size / 2f, min * 2, size / 2f); PvCustomizerGUI.DrawTextDirect(area, label, textAnchor: PvAnchor.UpperRight); } } } }
private void DrawTintExample() { if (_folderExampleSprite == null) { _folderExampleSprite = Resource.Load <Sprite>("Icons/Game Elements/008-castle.png"); } Vector2 localBoundSize = _tintExampleContainer.localBound.size; Rect drawRect = GUILayoutUtility.GetRect(localBoundSize.x, localBoundSize.y); PvCustomizerGUI.DrawSprite(drawRect, _folderExampleSprite, tint: PvCustomizerGUI.ICON_SELECTED_TINT); }
public void Draw(object value, Rect fullRect, bool selected, IconStyle style) { if (!(value is Color color)) { return; } PvCustomizerGUI.DrawColor(style.DrawRect, color * style.Tint); if (style.CustomValues.Length > 0) { var drawText = (bool)style.CustomValues[0]; if (drawText) { PvCustomizerGUI.DrawText(style.DrawRect, color.ToString(), out Rect occupado); } } }
public void Draw(object value, Rect fullRect, bool selected, IconStyle style) { if (!(value is AudioClip clip)) { return; } if (!AssetDatabase.Contains(clip)) { //TODO } else { var tex = AssetPreview.GetAssetPreview(clip); PvCustomizerGUI.DrawTexture(style.DrawRect, tex, PvCustomizerGUI.AssetPreviewClipMaterial, style.Tint, style.ScaleMode); } }
public void Draw(object value, Rect fullRect, bool selected, IconStyle style) { if (!(value is Material material)) { return; } if (!AssetDatabase.Contains(material) || material.GetTag("PreviewType", false) == "Plane") { PvCustomizerGUI.DrawTexture(style.DrawRect, Texture2D.whiteTexture, material, style.Tint, style.ScaleMode); } else { var tex = AssetPreview.GetAssetPreview(material); PvCustomizerGUI.DrawTexture(style.DrawRect, tex, material, style.Tint, style.ScaleMode); } /* * Mesh mesh = PvCustomizerUtility.GetPrimitiveMesh(material.GetTag("PreviewType", false, "Sphere")); * * foreach (Type type in TypeCache.GetTypesDerivedFrom<ObjectPreview>()) * { * foreach (object attr in type.GetCustomAttributes(typeof(CustomPreviewAttribute), false)) * { * if (!(attr is CustomPreviewAttribute cust)) continue; * FieldInfo fieldInfo = * typeof(CustomPreviewAttribute).GetField("m_Type", * BindingFlags.Instance | BindingFlags.NonPublic); * Type held = fieldInfo. * GetValue(cust) as Type; * if (held != typeof(Material)) continue; * Debug.Log($"Found material preview: {held.Name}."); * * var preview = Activator.CreateInstance(held) as ObjectPreview; * preview.OnPreviewGUI(style.DrawRect, GUIStyle.none); * } * }*/ }