Example #1
0
 public static void            DeleteAllSaves()
 {
     DebugFormat.Log <Saver <T> >($"path: {PERSISTANT_DATA_PATH}");
     if (Directory.Exists(PERSISTANT_DATA_PATH))
     {
         Directory.Delete(PERSISTANT_DATA_PATH, true);
     }
 }
Example #2
0
    protected override void OnAfterClick()
    {
        base.OnAfterClick();

        if (autoSwitchStates && isAcceptMode.Value == acceptStateBeforeClick)
        {
            DebugFormat.Log(this, "Auto switch");
            isAcceptMode.Value = !isAcceptMode.Value;
        }
    }
Example #3
0
 protected virtual bool Open(T unit)
 {
     if (IsOpen)
     {
         return(Open());
     }
     DebugFormat.Log(this, gameObject.name);
     ((Subject <T>)OnOpen).OnNext(lastUnit = unit);
     return(Open());
 }
Example #4
0
 protected override void                                    OnDataLoaded(SaveData data)
 {
     DebugFormat.Log(this);
     Data = new SaveData()
     {
         accessToken  = data.accessToken,
         refreshToken = data.refreshToken
     };
     AccessTokenHeader = Data.accessToken;
 }
Example #5
0
    public DebugRequestEvents(CompositeDisposable compositeDisposable, Request <T> request, int id) : base()
    {
#if UNITY_EDITOR
        OnSuccess.Subscribe(x => DebugFormat.Log <Request <T> >($"[{request.RESTMethod}] {id} - OnSuccess\n\n{JsonConvert.SerializeObject(x, Formatting.Indented)}\n", deep: DEEP)).AddTo(compositeDisposable);
        OnSuccessRaw.Subscribe(x => DebugFormat.Log <Request <T> >($"[{request.RESTMethod}] {id} - OnSuccessRaw\n\n{Request<T>.JsonPrettify(x)}\n", deep: DEEP)).AddTo(compositeDisposable);
#endif
        OnSerializationError.Subscribe(x => DebugFormat.LogError <Request <T> >($"[{request.RESTMethod}] {id} - OnSerializationError: {x}", deep: DEEP)).AddTo(compositeDisposable);
        OnHttpError.Subscribe(x => DebugFormat.LogError <Request <T> >($"[{request.RESTMethod}] {id} - OnHttpError\n\n {JsonConvert.SerializeObject(x, Formatting.Indented)}\n", deep: DEEP)).AddTo(compositeDisposable);
        OnHttpErrorRaw.Subscribe(x => DebugFormat.LogError <Request <T> >($"[{request.RESTMethod}] {id} - OnHttpErrorRaw\n\n{x}\n", deep: DEEP)).AddTo(compositeDisposable);
        OnNetworkError.Subscribe(x => DebugFormat.LogError <Request <T> >($"[{request.RESTMethod}] {id} - OnNetworkError\n\n {JsonConvert.SerializeObject(x, Formatting.Indented)}\n", deep: DEEP)).AddTo(compositeDisposable);
    }
Example #6
0
    protected override void                                    OnEnable()
    {
        AccessTokenHeader = null;

        base.OnEnable();
        DebugFormat.Log(this);

        compositeDisposable.Clear();
        GlobalEvents.OnHttpError.Where(httpError => httpError.httpResponseCode == AccessTokenExpiredCode)
        .Subscribe(httpError => SetToken(null, null))
        .AddTo(compositeDisposable);
    }
Example #7
0
    protected virtual void Close(T unit)
    {
        if (!IsOpen)
        {
            Close();
            return;
        }

        Close();
        DebugFormat.Log(this, gameObject.name);
        ((Subject <T>)OnClose).OnNext(lastUnit);
        lastUnit = null;
    }
    protected override UnityWebRequest CreateUnityWebRequest(string endpoint)
    {
        var json     = JsonConvert.SerializeObject(data);
        var byteData = Encoding.UTF8.GetBytes(json);

#if UNITY_EDITOR
        try                                             { DebugFormat.Log <RequestPost <T1, T2> >($"JSON {RESTMethod}:\n\n{JsonPrettify(json)}\n"); }
        catch (Exception e)             { DebugFormat.Log <RequestPost <T1, T2> >($"JSON {RESTMethod}:\n\n{json}\n"); }
#endif

        return(new UnityWebRequest(endpoint)
        {
            method = RESTMethod,
            uploadHandler = new UploadHandlerRaw(byteData),
            downloadHandler = new DownloadHandlerBuffer()
        });
    }
Example #9
0
    public async UniTask <Request <T> > SendRequest <T>          (Request <T> request)
    {
        var compositeDisposable = request.Events.Subscribe(GlobalEvents);

        if (debug)
        {
            var id = Request <T> .IncrementalID;

            DebugFormat.Log(this, $"[{request.RESTMethod}] {id} - {request.RequestURL}", this);
            if (debugHeaders)
            {
                var headers = request.GetHeaders();
                foreach (var key in headers.Keys)
                {
                    DebugFormat.Log(this, $"Header {key} : {headers[key]}");
                }
            }
            var debugEvents = new DebugRequestEvents <T>(compositeDisposable, request, id);
            compositeDisposable.Add(request.Events.Subscribe(debugEvents));
        }

        await request.SendRequest();

        if (debug && debugHeaders && request.LastUnityRequest != null)
        {
            if (debugHeaders)
            {
                var headers = request.LastUnityRequest.GetResponseHeaders();
                foreach (var key in headers.Keys)
                {
                    DebugFormat.Log(this, $"Response Header {key} : {headers[key]}");
                }
            }
        }
        compositeDisposable.Dispose();
        return(request);

#if UNITY_EDITOR && ZENJECT
        if (!Application.isPlaying && Zenject.ProjectContext.HasInstance)
        {
            DestroyImmediate(Zenject.ProjectContext.Instance.gameObject);
        }
#endif
    }
Example #10
0
 protected virtual void OnHideAnimationCompleted()
 {
     DebugFormat.Log(this);
     gameObject.SetActive(false);
 }
Example #11
0
 protected virtual void OnShowAnimationCompleted()
 {
     DebugFormat.Log(this);
 }