65 lines
2.7 KiB
C#
65 lines
2.7 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using ZGame;
|
|
|
|
namespace HK.FUJIFILM
|
|
{
|
|
public class SquareCoaster_Model : Model_Fixed
|
|
{
|
|
protected override void ProduceDesign_CopyDesignItemAssetEvent(object sender, GameEventArgs e)
|
|
{
|
|
var args = e as ProduceDesign_CopyDesignItemAssetEventArgs;
|
|
designItems.Clear();
|
|
for (var i = 0; i < designParent.transform.childCount; i++)
|
|
{
|
|
GameObject.Destroy(designParent.transform.GetChild(i).gameObject);
|
|
}
|
|
|
|
productScriptableObject = args.productScriptableObject;
|
|
designParent.GetComponent<Image>().sprite = args.sprite;
|
|
var instantiate = GameObject.Instantiate(args.go, designParent);
|
|
if (instantiate.TryGetComponent(typeof(Image), out var image))
|
|
{
|
|
var component = ((Image)image);
|
|
component.sprite = args.sprite;
|
|
component.enabled = productScriptableObject.isShowTemplate;
|
|
}
|
|
|
|
option = instantiate.GetComponent<RenderPrintingManagerOption>();
|
|
var gridLayoutGroup = instantiate.GetComponent<GridLayoutGroup>();
|
|
if (gridLayoutGroup != null)
|
|
{
|
|
gridLayoutGroup.constraint = option.constraint;
|
|
gridLayoutGroup.constraintCount = option.constraintCount;
|
|
gridLayoutGroup.spacing = option.spacing;
|
|
gridLayoutGroup.padding = option.padding;
|
|
gridLayoutGroup.cellSize = option.cellSize;
|
|
var rectTransform = instantiate.GetComponent<RectTransform>();
|
|
rectTransform.sizeDelta = designParent.sizeDelta;
|
|
rectTransform.localScale = option.modelScale;
|
|
rectTransform.anchoredPosition = option.modelPosition;
|
|
|
|
if (option.modelScale != Vector3.zero)
|
|
rectTransform.localScale = option.modelScale;
|
|
if (option.modelPosition != Vector2.zero)
|
|
rectTransform.anchoredPosition = option.modelPosition;
|
|
|
|
var itemParentTrans = instantiate.transform;
|
|
for (var i = 0; i < itemParentTrans.childCount; i++)
|
|
{
|
|
itemParentTrans.GetChild(i).GetChild(0).gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
instantiate.transform.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
|
|
var list = instantiate.transform.FindChildDeeps<ImageDesignItem>();
|
|
|
|
foreach (var imageDesignItem in list)
|
|
{
|
|
imageDesignItem.IsHideBtnAdd(true);
|
|
designItems.Add(imageDesignItem.ID, imageDesignItem);
|
|
}
|
|
}
|
|
}
|
|
} |