using System; using System.Collections.Generic; using Coffee.UIEffects; using FJson; using FJson.Core; using Framework.Timer; using UnityEngine; using UnityEngine.UI; using IcecreamView; using MintAnimation.Core; using Unity.Mathematics; namespace Views { public class LoadingPanel : IcecreamView.IC_AbstractModule { // [SerializeField] private UITransitionEffect _transitionEffect; [SerializeField] private Image _image; [SerializeField] private Image _image2; [SerializeField] private GameObject _tipObject; [SerializeField] private MintTweenOptions _mintTweenOptions; [SerializeField] private float _delay = 1; private MintTween _tween; private Material _material; private static readonly int Slider1 = Shader.PropertyToID("_progress"); private static readonly int Slider2 = Shader.PropertyToID("_SliderIcon"); // private Action _openedAction; public override void OnOpenView(IC_ViewData parameters) { Image img = parameters?.MsgCount > 0 ? (parameters.GetValue() == 1 ? _image : _image2) : _image; _image.gameObject.SetActive(ReferenceEquals(img, _image)); _image2.gameObject.SetActive(ReferenceEquals(img, _image2)); this._material = img.material; this.ViewConnector.Await(); this._tipObject.SetActive(false); // this._openedAction = parameters.GetValue (); this._tween = new MintTween(InAnim, 0, 1, this._mintTweenOptions); this._tween.OnceOnComplete = () => { this._tipObject.SetActive(true); GameUpdateMgr.Instance.CreateTimer(this._delay, this.ViewConnector.Continue); }; this._tween.Start(); } private void InAnim(float progress) { // this._transitionEffect.effectFactor = progress; this._material.SetFloat(Slider1, progress); // this._material.SetFloat (Slider2 , 1 -progress); //此处改一下逻辑, 0-0.7时 Slider1变为0, 0.7-1时 Slider2变为0 // if (progress < 0.7f) // { // var value = MintEaseAction.OutQuad (0 , 1 ,math.remap ( 0 , 0.7f , 1 , 0 , progress)); // this._material.SetFloat (Slider1 , value); // } // else // { // var value = math.remap ( 0.7f , 1 , 0 , 1 , progress); // this._material.SetFloat (Slider2 , value); // } } private void OutAnim(float progress) { // this._transitionEffect.effectFactor = 1 - progress; this._material.SetFloat(Slider1, 1 - progress); //此处逻辑, 0-0.7时 Slider1变为0, 0.7-1时 Slider2变为0 // if (progress < 0.7f) // { // var value = math.remap ( 0 , 0.7f , 0 , 1 , progress); // this._material.SetFloat (Slider1 , value); // } // else // { // var value = math.remap ( 0.7f , 1 , 0 , 1 , progress); // this._material.SetFloat (Slider2 , value); // } // //单独解析 // var a = ActionParser.CreateAction ("key" , "value" , true); // var b = ActionParser.CreateAction ("apString" , true); // //列表解析 // var singe = ActionReader.ReadActionParser ("apString"); // var array = ActionReader.ReadActionParsers ("apString\napString apString3"); } public override void OnCloseView() { this._tipObject.SetActive(false); this.ViewConnector.Await(); this._tween = new MintTween(OutAnim, 0, 1, this._mintTweenOptions); this._tween.OnceOnComplete = this.ViewConnector.Continue; this._tween.Start(); } } }