123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System;
- using UnityEngine;
- using wf;
- public class ScenePresetWindow : BaseMaidPhotoWindow
- {
- public override void Awake()
- {
- base.Awake();
- PhotoScenePreset.Create();
- }
- public override void Start()
- {
- base.Start();
- this.Init();
- }
- public void Init()
- {
- for (int i = 0; i < PhotoScenePreset.datas.Count; i++)
- {
- this.CreateScenePresetButton(this.contentGrid.gameObject, PhotoScenePreset.datas[i]);
- }
- Utility.ResetNGUI(this.contentGrid);
- Utility.ResetNGUI(NGUITools.FindInParents<UIScrollView>(this.contentGrid.transform));
- this.UpdateChildren();
- }
- public override void OnDeserializeEvent()
- {
- ScenePresetWindow.SelectData = null;
- }
- public GameObject CreateScenePresetButton(GameObject parentObject, PhotoScenePreset.Data data)
- {
- GameObject gameObject = Utility.CreatePrefab(parentObject, "ScenePhotoMode/ScenePresetButton", true);
- gameObject.name = data.id.ToString();
- UI2DSprite component = UTY.GetChildObject(gameObject, "Plate/Plate/BG/ThumImage", false).GetComponent<UI2DSprite>();
- if (!string.IsNullOrEmpty(data.thumbnailName))
- {
- Texture2D texture2D = ImportCM.CreateTexture(data.thumbnailName + ".tex");
- Sprite sprite2D = Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), default(Vector2));
- if (component.sprite2D != null && component.sprite2D.texture != null)
- {
- UnityEngine.Object.DestroyImmediate(component.sprite2D.texture);
- }
- component.sprite2D = sprite2D;
- component.SetDimensions(texture2D.width, texture2D.height);
- }
- UIButton componentInChildren = gameObject.GetComponentInChildren<UIButton>();
- componentInChildren.name = data.id.ToString();
- EventDelegate.Add(componentInChildren.onClick, new EventDelegate.Callback(this.OnClickLoadBtn));
- return gameObject;
- }
- private void OnClickLoadBtn()
- {
- int id = int.Parse(UIButton.current.name);
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/シチュ/ダイアログ/現在の配置情報はリセットされます。宜しいですか?", null, SystemDialog.TYPE.OK_CANCEL, delegate
- {
- GameMain.Instance.SysDlg.Close();
- this.Load(id);
- }, null);
- }
- private void Load(int id)
- {
- foreach (PhotoScenePreset.Data data in PhotoScenePreset.datas)
- {
- if (data.id == id)
- {
- byte[] array = null;
- using (AFileBase afileBase = GameUty.FileSystem.FileOpen(data.loadFileName))
- {
- array = afileBase.ReadAll();
- }
- if (array != null)
- {
- ScenePresetWindow.SelectData = data;
- base.mgr.SaveAndLoadManager.ReadSave(array);
- }
- break;
- }
- }
- }
- [HideInInspector]
- public static PhotoScenePreset.Data SelectData;
- [SerializeField]
- private UIGrid contentGrid;
- }
|