VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
AVR_Behaviour.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 
5 /// <summary>
6 /// Namespace of the arc-vr-core package
7 /// </summary>
8 namespace AVR.Core {
9  /// <summary>
10  /// Monobehaviour but with an added URL button to a documentation page.
11  /// </summary>
12  [AVR.Core.Attributes.DocumentationUrl("class_a_v_r_1_1_core_1_1_a_v_r___behaviour.html")]
13  public abstract class AVR_Behaviour :
14 #if AVR_NET
15  Unity.Netcode.NetworkBehaviour
16 #else
17  MonoBehaviour
18 #endif
19  {
20  /// <summary>
21  /// The current AVR_PlayerRig instance in the scene
22  /// </summary>
23  protected AVR_PlayerRig playerRig => AVR_PlayerRig.Instance;
24 
25  /// <summary>
26  /// The current AVR_Root instance in the scene
27  /// </summary>
28  protected AVR_Root root => AVR_Root.Instance;
29 
30  /// <summary>
31  /// True if the application is running as a VR/XR application
32  /// </summary>
33  protected bool vrEnabled => UnityEngine.XR.XRSettings.enabled;
34 
35 #if AVR_NET
36  /// <summary>
37  /// This method works exaclty as regular MLAPI NetworkBehaviour.HasNetworkObject, except that it *only checks once* for NetworkObjects
38  /// </summary>
39  new public bool HasNetworkObject {
40  get {
41  if(!networkobj_checked) networkobj_connected = base.HasNetworkObject;
42  networkobj_checked = true;
43  return networkobj_connected;
44  }
45  }
46  private bool networkobj_checked = false;
47  private bool networkobj_connected = false;
48 
49  /// <summary>
50  /// True if we are hosting or connected to a network
51  /// </summary>
52  protected bool IsOnline => HasNetworkObject && NetworkManager && (IsServer || IsClient);
53 
54  /// <summary>
55  /// Returns true if we are the network owner of this script or of we are not online.
56  /// </summary>
57  new public bool IsOwner => !this.IsOnline || base.IsOwner;
58 #else
59  // We define OnDestroy here to keep consistency with Networkbehaviour
60  public virtual void OnDestroy()
61  {
62 
63  }
64 #endif
65  }
66 }
Monobehaviour but with an added URL button to a documentation page.
Represents the players VR setup. Only one instance at a time is allowed.
Sets the documentation html file inside of Packages/com.avr.core/Documentation/html of a given class...
virtual void OnDestroy()
Root object of the arc-vr-core library. Functions as a Singleton.
Definition: AVR_Root.cs:13