171 lines
6.6 KiB
C#
171 lines
6.6 KiB
C#
using System.Collections.Generic;
|
|
using HK;
|
|
using HK.FUJIFILM;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using ZGame;
|
|
|
|
public class MugActualModelRender_Fixed : Model_Fixed
|
|
{
|
|
public RectTransform designParent;
|
|
public ProductScriptableObject productScriptableObject;
|
|
|
|
private void OnEnable()
|
|
{
|
|
EventManager.Instance.Subscribe(MugActualModel_Fixed_GenPhotoEventArgs.EventId,
|
|
MugActualModel_Fixed_GenPhotoEvent);
|
|
EventManager.Instance.Subscribe(ProduceDesign_CopyDesignItemAssetEventArgs.EventId,
|
|
ProduceDesign_CopyDesignItemAssetEvent);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
EventManager.Instance.Unsubscribe(MugActualModel_Fixed_GenPhotoEventArgs.EventId,
|
|
MugActualModel_Fixed_GenPhotoEvent);
|
|
EventManager.Instance.Unsubscribe(ProduceDesign_CopyDesignItemAssetEventArgs.EventId,
|
|
ProduceDesign_CopyDesignItemAssetEvent);
|
|
}
|
|
|
|
private void MugActualModel_Fixed_GenPhotoEvent(object sender, GameEventArgs e)
|
|
{
|
|
return;
|
|
|
|
var args = e as MugActualModel_Fixed_GenPhotoEventArgs;
|
|
if (!designItems.TryGetValue(args.ID, out ImageDesignItem designItem))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var loadGameObject = GameObject.Instantiate(args.go, designItem.DesignParent);
|
|
|
|
loadGameObject.transform.localPosition = args.go.transform.localPosition;
|
|
var image = loadGameObject.GetComponent<Image>();
|
|
loadGameObject.AddComponent<HK.UpdateTransform>().SetData(args.go.transform);
|
|
loadGameObject.SetActive(true);
|
|
}
|
|
|
|
Dictionary<string, ImageDesignItem> designItems = new Dictionary<string, ImageDesignItem>();
|
|
|
|
private void ProduceDesign_CopyDesignItemAssetEvent(object sender, GameEventArgs e)
|
|
{
|
|
return;
|
|
|
|
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;
|
|
}
|
|
|
|
// only (pet id card)
|
|
OnlyPetIDCard(instantiate, args);
|
|
|
|
// only (one to many)
|
|
var gridLayoutGroup = instantiate.GetComponent<GridLayoutGroup>();
|
|
if (gridLayoutGroup != null)
|
|
{
|
|
gridLayoutGroup.constraint = args.productScriptableObject.constraint_OnceToMany;
|
|
gridLayoutGroup.constraintCount = args.productScriptableObject.constraintCount_OnceToMany;
|
|
gridLayoutGroup.spacing = args.productScriptableObject.layoutSpacingSize_OnceToMany;
|
|
gridLayoutGroup.padding = args.productScriptableObject.layoutRectOffset_OnceToMany;
|
|
gridLayoutGroup.cellSize = args.productScriptableObject.cellSize_OnceToMany;
|
|
var rectTransform = instantiate.GetComponent<RectTransform>();
|
|
rectTransform.sizeDelta = designParent.sizeDelta;
|
|
|
|
var itemParentTrans = instantiate.transform;
|
|
for (var i = 0; i < itemParentTrans.childCount; i++)
|
|
{
|
|
itemParentTrans.GetChild(i).GetChild(0).gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
if (args.productScriptableObject.produceID == "34610401")
|
|
{
|
|
OnlyPhotoFilmRollKeychain(instantiate);
|
|
}
|
|
|
|
if (args.productScriptableObject.produceID == "34610102")
|
|
{
|
|
OnlyDoubleSideCushion(instantiate);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
void OnlyPetIDCard(GameObject instantiate, ProduceDesign_CopyDesignItemAssetEventArgs args)
|
|
{
|
|
var componentInChildren = args.go.GetComponentInChildren<UpdateInput>();
|
|
var updateInput = instantiate.GetComponentInChildren<UpdateInput>();
|
|
if (componentInChildren != null && updateInput != null)
|
|
updateInput.SetData(componentInChildren.inpChinName, componentInChildren.inpEngName,
|
|
componentInChildren.inpID, componentInChildren.inpID1, componentInChildren.inpID2,
|
|
componentInChildren.inpBirth, componentInChildren.inpBirth1, componentInChildren.inpBirth2,
|
|
componentInChildren.inpIssue, componentInChildren.inpIssue1, componentInChildren.droSex,
|
|
componentInChildren.inpBianHao);
|
|
}
|
|
|
|
void OnlyPhotoFilmRollKeychain(GameObject instantiate)
|
|
{
|
|
return;
|
|
Vector2 pos = new Vector2(-382, -194);
|
|
Vector2 size = new Vector2(1462.38f, 1035.8f);
|
|
Vector3 scale = new Vector3(0.2f, 0.2f, 0.2f);
|
|
|
|
var rectTransform = instantiate.transform.GetComponent<RectTransform>();
|
|
rectTransform.anchoredPosition = pos;
|
|
rectTransform.sizeDelta = size;
|
|
rectTransform.localScale = scale;
|
|
var child = rectTransform.GetChild(0);
|
|
child.GetComponent<RectTransform>().anchoredPosition = new Vector2(-1955f, 0);
|
|
child.GetComponent<Image>().enabled = false;
|
|
child.GetComponent<Mask>().enabled = false;
|
|
rectTransform.GetChild(1).gameObject.SetActive(false);
|
|
}
|
|
|
|
void OnlyDoubleSideCushion(GameObject instantiate)
|
|
{
|
|
return;
|
|
var layoutGroup = designParent.GetComponent<VerticalLayoutGroup>();
|
|
bool tmpEnable = layoutGroup.enabled;
|
|
layoutGroup.enabled = true;
|
|
|
|
var child = designParent.GetChild(0);
|
|
if (child.TryGetComponent(typeof(GridLayoutGroup), out var grid))
|
|
{
|
|
((GridLayoutGroup)grid).enabled = true;
|
|
}
|
|
|
|
return;
|
|
|
|
var binding = instantiate.transform.GetChild(0).GetComponent<UIGameObjectBinding>();
|
|
var allValue = binding.GetAllValue();
|
|
foreach (var go in allValue)
|
|
{
|
|
go.transform.GetChild(0).gameObject.SetActive(true);
|
|
}
|
|
|
|
var binding1 = instantiate.transform.GetChild(1).GetComponent<UIGameObjectBinding>();
|
|
var allValue1 = binding1.GetAllValue();
|
|
foreach (var go in allValue1)
|
|
{
|
|
go.transform.GetChild(0).gameObject.SetActive(true);
|
|
}
|
|
}
|
|
} |