This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // AuthenticationManager.cs | |
| public Task SignInAnonymously() | |
| { | |
| return auth.SignInAnonymouslyAsync().ContinueWith(task => | |
| { | |
| if (task.IsCanceled) | |
| { | |
| Debug.LogError("SignInAnonymouslyAsync was canceled."); | |
| OnSignInFailed?.Invoke(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import FirebaseFirestore | |
| class FirestoreStore<T: FirestoreModel> { | |
| private var listener: ListenerRegistration? | |
| func listenDocument(documentID: String, completion: @escaping (Result<T, Error>) -> Void) { | |
| unlisten() | |
| listener = T.collectionRef.document(documentID).addSnapshotListener { (documentSnapshot, error) in | |
| guard let document = documentSnapshot else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import FirebaseAuth | |
| class AuthenticationStore: ObservableObject { | |
| var handle: AuthStateDidChangeListenerHandle? | |
| func listen(completion: @escaping (FirebaseAuth.User?) -> Void) { | |
| handle = Auth.auth().addStateDidChangeListener { (auth, authUser) in | |
| completion(authUser) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const ProtectedRoute = ({ component: Component, ...rest }) => ( | |
| <Route {...rest} render={(props) => ( | |
| auth.isAuthenticated ? | |
| <Component {...props} /> : <Redirect to={{ pathname: '/login', state: { from: props.location }}} /> | |
| )} /> | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // State.cs | |
| public class State : ScriptableObject | |
| { | |
| public Transition transition; | |
| private bool canChangeState; | |
| // Called each frame | |
| public void UpdateState (StateMachine _stateMachine) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // State.cs | |
| using UnityEngine.Events; | |
| [CreateAssetMenu] | |
| public class State : ScriptableObject | |
| { | |
| public UnityEvent enterStateEvent; | |
| public UnityEvent exitStateEvent; |