コード例 #1
0
    public static void StartMusic()
    {
        MusicManager managerInstance = ResourcesExtensions.InstantiateFromResources <MusicManager>(prefabPath, null);

        instance = managerInstance;
        DontDestroyOnLoad(managerInstance);
    }
コード例 #2
0
ファイル: UIBlocker.cs プロジェクト: BenjiBoy926/UnityAssets
    public static UIBlocker Create(Transform requester)
    {
        // Make sure the requester is not null
        if (!requester)
        {
            throw new System.ArgumentNullException(nameof(requester));
        }

        Canvas canvas = requester.GetComponentInParent <Canvas>();

        // If there is no canvas in the parent then throw exception
        if (!canvas)
        {
            throw new System.ArgumentException(
                      $"Cannot request a UIBlocker for object {requester} " +
                      $"because it is not a canvas or a child of a canvas!");
        }

        // Make sure we have the root canvas
        canvas = canvas.rootCanvas;

        // Create a UI blocker from resources
        UIBlocker instance = ResourcesExtensions.InstantiateFromResources <UIBlocker>(nameof(UIBlocker), canvas.transform);

        instance.transform.SetAsLastSibling();

        return(instance);
    }
コード例 #3
0
 public static TutorialUI InstantiateFromResources(Transform parent, string resourcePath = null)
 {
     if (string.IsNullOrWhiteSpace(resourcePath))
     {
         resourcePath = defaultResourcePath;
     }
     return(ResourcesExtensions.InstantiateFromResources <TutorialUI>(resourcePath, parent));
 }
コード例 #4
0
 public static GenericYesNoWindow InstantiateFromResource(Transform parent, string prefabPath = null)
 {
     if (string.IsNullOrWhiteSpace(prefabPath))
     {
         prefabPath = defaultPrefabPath;
     }
     return(ResourcesExtensions.InstantiateFromResources <GenericYesNoWindow>(prefabPath, parent));
 }
コード例 #5
0
ファイル: UnlockUI.cs プロジェクト: BenjiBoy926/OneDiagonal2
 public static UnlockUI InstantiateFromResources(Transform parent, string prefabPath = null)
 {
     if (string.IsNullOrWhiteSpace(prefabPath))
     {
         prefabPath = defaultResourcePath;
     }
     return(ResourcesExtensions.InstantiateFromResources <UnlockUI>(prefabPath, parent));
 }
コード例 #6
0
    public static void Initialize()
    {
        // Instantiate the effects manager from the resources and make it not destroy on load
        instance = ResourcesExtensions.InstantiateFromResources <OutlineManager>(nameof(OutlineManager), null);
        DontDestroyOnLoad(instance);

        // Re-initialize the pools on scene loaded
        SceneManager.sceneLoaded += instance.OnSceneLoaded;
    }
コード例 #7
0
ファイル: DebuggingUI.cs プロジェクト: tg1230/Space-Zoologist
    public static void CreateDebuggingUI()
    {
        if (!instance)
        {
            instance = ResourcesExtensions.InstantiateFromResources <DebuggingUI>(prefabPath, null);
            DontDestroyOnLoad(instance.gameObject);

            // Update the ui each time that a new scene is loaded
            SceneManager.sceneLoaded += instance.UpdateUI;
        }
    }
コード例 #8
0
    public static void CreateInstance()
    {
        if (!instance)
        {
            // Try to instantiate the component from the resources folder
            string typename = typeof(BehaviourType).Name;
            instance = ResourcesExtensions.InstantiateFromResources <BehaviourType>(typename, null);

            // Make the instance not destroyed on load
            DontDestroyOnLoad(instance);
        }
    }
コード例 #9
0
 public static void Initialize()
 {
     instance = ResourcesExtensions.InstantiateFromResources <AudioPanel>(nameof(AudioPanel), null);
     DontDestroyOnLoad(instance);
 }