コード例 #1
0
 private void OnScreenDestroyed(IScreenController screen)
 {
     if (registeredScreens.ContainsKey(screen.GetType()))
     {
         UnregisterScreen((T)screen);
     }
 }
コード例 #2
0
        private bool IsPrefabValid(IScreenController screen)
        {
            Component screenAsComponent = screen as Component;

            if (screenAsComponent == null)
            {
                Debug.LogError($"The Screen to register must derive from {typeof(Component).Name}");
                return(false);
            }

            if (IsPrefab(screenAsComponent.gameObject) == false)
            {
                Debug.LogError($"{screenAsComponent.gameObject.name} must be a Prefab.");
                return(false);
            }

            if (registeredScreens.TryGetValue(screen.GetType(), out ScreenEntry entry) && entry.ScreenPrefab != screen)
            {
                Debug.LogError($"{screen.GetType().Name} already registered with a different Prefab.");
                return(false);
            }

            return(true);
        }