Tilt Five™ Unity API  1.4.1
TiltFiveSingletonHelper.cs
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020-2023 Tilt Five, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 using System.Collections;
17 using System.Collections.Generic;
18 using UnityEngine;
19 
20 namespace TiltFive
21 {
22  public interface ISceneInfo
23  {
26  Camera GetEyeCamera();
29  }
30 
31  public static class TiltFiveSingletonHelper
32  {
33  public static ISceneInfo GetISceneInfo()
34  {
35  TryGetISceneInfo(out var singleplayerSingleton);
36  return singleplayerSingleton;
37  }
38 
39  public static bool TryGetISceneInfo(out ISceneInfo sceneInfo)
40  {
41  if (TiltFiveManager2.IsInstantiated)
42  {
43  sceneInfo = TiltFiveManager2.Instance;
44  return true;
45  }
46 
47  if (TiltFiveManager.IsInstantiated)
48  {
49  sceneInfo = TiltFiveManager.Instance;
50  return true;
51  }
52 
53  // The TiltFiveManager2 or TiltFiveManager won't appear to be instantiated
54  // until their Awake() functions are called. If we're calling from the editor
55  // outside of play mode, just scan the scene.
56  // Presumably this is being called from a menu script, gizmo, etc.
57  if (!Application.isPlaying)
58  {
59  var tiltFiveManager2 = GameObject.FindObjectOfType<TiltFiveManager2>();
60  if (tiltFiveManager2 != null)
61  {
62  sceneInfo = tiltFiveManager2;
63  return true;
64  }
65 
66  var tiltFiveManager = GameObject.FindObjectOfType<TiltFiveManager>();
67  if (tiltFiveManager != null)
68  {
69  sceneInfo = tiltFiveManager;
70  return true;
71  }
72  }
73 
74  sceneInfo = null;
75  return false;
76  }
77  }
78 }
The Tilt Five manager.
The Tilt Five manager.
static bool TryGetISceneInfo(out ISceneInfo sceneInfo)
uint GetSupportedPlayerCount()
float GetScaleToUWRLD_UGBD()
Definition: Log.cs:21