123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using System;
- using System.IO;
- using UnityEngine;
- public class PhotoModeObjectSave : MonoBehaviour
- {
- public void Awake()
- {
- EventDelegate.Add(UTY.GetChildObject(base.gameObject, "Base/Ok", false).GetComponent<UIButton>().onClick, new EventDelegate.Callback(this.OnBtnOk));
- EventDelegate.Add(UTY.GetChildObject(base.gameObject, "Base/Cancel", false).GetComponent<UIButton>().onClick, new EventDelegate.Callback(this.OnBtnCancel));
- }
- public void Start()
- {
- }
- public void Open(BasePhotoCustomObject saveObject, Action<string> successCallBack)
- {
- this.saveObject = saveObject;
- this.successCallBack = successCallBack;
- base.gameObject.SetActive(true);
- TweenAlpha tweenAlpha = base.gameObject.AddComponent<TweenAlpha>();
- tweenAlpha.from = 0f;
- tweenAlpha.to = 1f;
- tweenAlpha.duration = 0.3f;
- tweenAlpha.PlayForward();
- EventDelegate.Set(tweenAlpha.onFinished, delegate
- {
- TweenAlpha component = base.gameObject.GetComponent<TweenAlpha>();
- if (component != null)
- {
- UnityEngine.Object.DestroyImmediate(component);
- }
- });
- }
- public void OnBtnOk()
- {
- this.InputPoseName.RemoveFocus();
- char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
- string text = this.InputPoseName.value;
- if (string.IsNullOrEmpty(text))
- {
- GameMain.Instance.SysDlg.Show("オブジェクト名が記入されていません", SystemDialog.TYPE.OK, null, null);
- return;
- }
- if (0 <= text.IndexOfAny(invalidFileNameChars))
- {
- GameMain.Instance.SysDlg.Show("オブジェクト名に使用できない文字が使われています", SystemDialog.TYPE.OK, null, null);
- return;
- }
- text = ObjectCreateWindow.folder_path + "\\" + text + ".poj";
- if (250 < text.Length)
- {
- GameMain.Instance.SysDlg.Show("オブジェクト名が長すぎます", SystemDialog.TYPE.OK, null, null);
- return;
- }
- if (File.Exists(text))
- {
- GameMain.Instance.SysDlg.Show("データが既に存在しています\n別の名前を指定してください", SystemDialog.TYPE.OK, null, null);
- return;
- }
- this.Save(text);
- }
- public void Save(string file_name)
- {
- try
- {
- File.WriteAllBytes(file_name, this.saveObject.Serialize());
- }
- catch
- {
- GameMain.Instance.SysDlg.Show("オブジェクトの保存に失敗しました", SystemDialog.TYPE.OK, null, null);
- return;
- }
- if (this.successCallBack != null)
- {
- this.successCallBack(file_name);
- }
- GameMain.Instance.SysDlg.Show("オブジェクトを保存しました\nオブジェクト管理ウィンドウのマイオブジェクトから選択できます", SystemDialog.TYPE.OK, delegate
- {
- GameMain.Instance.SysDlg.Close();
- this.OnBtnCancel();
- }, null);
- }
- public void OnBtnCancel()
- {
- this.InputPoseName.RemoveFocus();
- if (this.is_fade_processed)
- {
- return;
- }
- TweenAlpha tweenAlpha = base.gameObject.AddComponent<TweenAlpha>();
- tweenAlpha.from = 1f;
- tweenAlpha.to = 0f;
- tweenAlpha.duration = 0.3f;
- tweenAlpha.PlayForward();
- EventDelegate.Set(tweenAlpha.onFinished, delegate
- {
- TweenAlpha component = base.gameObject.GetComponent<TweenAlpha>();
- if (component != null)
- {
- UnityEngine.Object.DestroyImmediate(component);
- }
- base.gameObject.SetActive(false);
- });
- }
- private bool is_fade_processed
- {
- get
- {
- TweenAlpha component = base.gameObject.GetComponent<TweenAlpha>();
- if (component != null && !component.enabled)
- {
- component.enabled = true;
- }
- return component != null;
- }
- }
- public PhotoWindowManager PhotoMgr;
- public UIInput InputPoseName;
- private BasePhotoCustomObject saveObject;
- private Action<string> successCallBack;
- }
|