com.soviby.unity.ui.ugui-to.../Assets/Editor/ScriptObject/SettingScriptObject.cs
2024-12-10 02:39:04 +08:00

63 lines
1.9 KiB
C#

#if UNITY_EDITOR
using Sirenix.OdinInspector;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro.EditorUtilities;
using Unity.Mathematics;
using UnityEngine;
namespace UguiToolkit.Editor
{
public class SettingScriptObject : SerializedScriptableObject
{
[LabelText("ui预制体存放路径"), FolderPath]
public string prefabForUIDirPath;
[LabelText("ui预制体通用组件存放路径"), FolderPath]
public string commonPrefabForUIDirPath;
public float distanceDifference = 0.75f;
public bool useTMP;
// 项目配置
public List <TextFontPresetOfUnity> textFontList = new ();
}
[Serializable]
public class TextFontPresetOfUnity
{
[Title("Ps属性")]
public string name;
public List<string> fontNameOfPsd;
[LabelText("是否描边")]
public bool stroke; // 使用描边
public Color strokeColor;
public float strokeColorThreshold;
public bool allStrokeColor;
[LabelText("是否阴影")]
public bool shadow; // 使用阴影
public Color shadowColor;
public float shadowColorThreshold;
public bool allShadowColor;
[Title("Unity属性")]
[LabelText("长宽偏移")]
public float2 sizeOffset;
public TMPro.TMP_FontAsset tmpAsset;
[ShowIf(nameof(ShowMaterialPreset)), ValueDropdown(nameof(GetAllMaterialPreset), IsUniqueList = true)]
public string materialPreset;
private bool ShowMaterialPreset => tmpAsset;
private IEnumerable GetAllMaterialPreset()
{
if (tmpAsset != null)
return TMP_EditorUtility.FindMaterialReferences(tmpAsset)
.Select(x => new ValueDropdownItem(x.name, x.name));
return null;
}
}
}
#endif