136 lines
4.7 KiB
C#
136 lines
4.7 KiB
C#
using System.Collections.Generic;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
using UnityEngine.UI;
|
|
|
|
namespace HK
|
|
{
|
|
[CreateAssetMenu(fileName = "ProductObject", menuName = "ScriptableObjects/ProductObject", order = 1)]
|
|
public class ProductScriptableObject : ThemeBaseScriptableObject
|
|
{
|
|
[LabelText("产品名称")] public string produceName;
|
|
[LabelText("产品缩略图")] public Sprite icon;
|
|
[LabelText("是否能进入下一步")] public bool isCanGoNext = false;
|
|
[LabelText("模板")] public Sprite[] templateSprites;
|
|
[LabelText("是否显示模板图片内容")] public bool isShowTemplate = true;
|
|
|
|
[BoxGroup("GridLayout")] [LabelText("Template参数RectOffset")]
|
|
public RectOffset layoutRectOffset;
|
|
|
|
[BoxGroup("GridLayout")] [LabelText("Template参数cellSize")]
|
|
public Vector2 cellSize;
|
|
|
|
[BoxGroup("GridLayout")] [LabelText("Template参数SpacingSize")]
|
|
public Vector2 layoutSpacingSize;
|
|
|
|
[BoxGroup("GridLayout")] [LabelText("Template参数SpacingSize")]
|
|
public GridLayoutGroup.Constraint constraint;
|
|
|
|
[BoxGroup("GridLayout")] [LabelText("Template参数SpacingSize")]
|
|
public int constraintCount;
|
|
|
|
[Sirenix.OdinInspector.FilePath] [ReadOnly]
|
|
public string productUIPfbPath;
|
|
|
|
[LabelText("UI")] public GameObject productUIPrefab;
|
|
public bool is2D;
|
|
public Vector3 modelPosition;
|
|
|
|
[Sirenix.OdinInspector.FilePath] [ReadOnly]
|
|
public string productGameObjectPfbPath;
|
|
|
|
[LabelText("模型")] public GameObject productGameObjectPrefab;
|
|
[LabelText("是否需要显示协议页面")] public bool isShowTermPage;
|
|
|
|
[LabelText("截图尺寸")] public Vector2 screenshotSize;
|
|
[LabelText("印刷尺寸,单位mm")] public Vector2 printingSize;
|
|
[LabelText("产品价格")] public int productPrice;
|
|
[LabelText("设计价格")] public int designPrice;
|
|
public int discountPrice;
|
|
|
|
[Sirenix.OdinInspector.FilePath] [ReadOnly]
|
|
public string productShopCartItemPfbPath;
|
|
|
|
[LabelText("购物车Item")] public GameObject productShopCartItemPrefab;
|
|
|
|
[LabelText("可设计的总数,必须跟模板对应上")] public List<DesignItem> designItems = new List<DesignItem>();
|
|
public Sprite[] photoSprites;
|
|
[LabelText("是否只允许贴一张")] public bool isOnlyOne;
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
[Button("自动同步icon名字")]
|
|
public void AutoChangeName()
|
|
{
|
|
produceName = icon.name;
|
|
AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(Selection.activeObject), produceName);
|
|
}
|
|
|
|
[Button("自动同步预制体路径")]
|
|
public void AutoChangeProductUIPfbPath()
|
|
{
|
|
if (productUIPrefab != null)
|
|
productUIPfbPath = AssetDatabase.GetAssetPath(productUIPrefab);
|
|
if (productGameObjectPrefab != null)
|
|
productGameObjectPfbPath = AssetDatabase.GetAssetPath(productGameObjectPrefab);
|
|
if (productShopCartItemPrefab != null)
|
|
productShopCartItemPfbPath = AssetDatabase.GetAssetPath(productShopCartItemPrefab);
|
|
foreach (var designItem in designItems)
|
|
{
|
|
designItem.AutoInputIconName();
|
|
}
|
|
|
|
AssetDatabase.SaveAssets();
|
|
}
|
|
#endif
|
|
}
|
|
|
|
[System.Serializable]
|
|
public enum LayoutType
|
|
{
|
|
Horizontal,
|
|
Vertical,
|
|
Grid
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class DesignItem
|
|
{
|
|
// [HK.PropertyAttribute.FilePath("Assets/Res/Texture/ProductIcon")]
|
|
[ReadOnly] [Sirenix.OdinInspector.FilePath]
|
|
public string designItemAssetPath;
|
|
|
|
[LabelText("设计Item")] public GameObject designItemPrefab;
|
|
|
|
public string description;
|
|
public int designItemId;
|
|
public LayoutType layoutType;
|
|
|
|
public int designItemCount;
|
|
[SerializeField] public RectOffset layoutRectOffset;
|
|
|
|
[ShowIf("CheckIsNotGrid")] public float layoutSpacing;
|
|
|
|
[ShowIf("layoutType", LayoutType.Grid)]
|
|
public Vector2 cellSize;
|
|
|
|
[ShowIf("layoutType", LayoutType.Grid)]
|
|
public Vector2 layoutSpacingSize;
|
|
[LabelText("印刷尺寸,单位mm")] public Vector2 printingSize;
|
|
|
|
public bool CheckIsNotGrid()
|
|
{
|
|
return layoutType == LayoutType.Vertical || layoutType == LayoutType.Horizontal;
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
public void AutoInputIconName()
|
|
{
|
|
if (designItemPrefab != null)
|
|
designItemAssetPath = AssetDatabase.GetAssetPath(designItemPrefab);
|
|
}
|
|
#endif
|
|
}
|
|
} |