NodeWorld

FluxScript

La référence est en anglais : elle est générée à partir des commentaires du code, écrits en anglais.

csharp
public abstract class FluxScript

Namespace NodeWorld.Flux.

Base class of the scripts of a world. A script is attached to a GameObject of the scene (a FluxBehaviour component in Unity) and receives the callbacks below, in the order of Unity's MonoBehaviour: Awake when it is created, Start before its first Update, then each frame FixedUpdate (per physics step), Update, the coroutines and async continuations, LateUpdate, OnBeforeRender. A script whose callback throws is stopped (no more callbacks) and the host logs the exception.

Properties

gameObject

csharp
public GameObject gameObject { get; }

The GameObject this script is on.

transform

csharp
public Transform transform { get; }

The Transform of the script's GameObject.

enabled

csharp
public bool enabled { get; set; }

A disabled script gets no Update, LateUpdate, FixedUpdate nor OnBeforeRender.

Methods

GetComponent<T>

csharp
public T GetComponent<T>()
    where T : Component

The component of that type on the GameObject of the script, or null.

GetScript<T>

csharp
public T GetScript<T>()
    where T : FluxScript

The FL# script of that class on the GameObject of this script (the first one), or null.

Awake

csharp
protected internal virtual void Awake()

Runs once when the script is created, after the scene set its fields: every script of the scene is created and set before the first Awake. It runs on an inactive object too.

Start

csharp
protected internal virtual void Start()

Runs once, before the first Update of the script, while its GameObject is active.

Update

csharp
protected internal virtual void Update()

Runs every frame while the script is enabled and its GameObject active.

LateUpdate

csharp
protected internal virtual void LateUpdate()

Runs every frame, after every Update, the coroutines and the async continuations.

FixedUpdate

csharp
protected internal virtual void FixedUpdate()

Runs at each physics step (Time.fixedDeltaTime).

OnBeforeRender

csharp
protected internal virtual void OnBeforeRender()

Runs every frame just before the frame is drawn: a mirror renders its reflection here.

OnDestroy

csharp
protected internal virtual void OnDestroy()

The GameObject of the script was destroyed, or the world unloads: the last callback of the script.

OnEnable

csharp
protected internal virtual void OnEnable()

The GameObject became active in the hierarchy (also right after Awake when it is active at load).

OnDisable

csharp
protected internal virtual void OnDisable()

The GameObject became inactive in the hierarchy: no Start, Update, LateUpdate, FixedUpdate nor OnBeforeRender until it is active again.

OnInteract

csharp
protected internal virtual void OnInteract()

The local player used the object (trigger pressed on it).

OnGrab

csharp
protected internal virtual void OnGrab()

The local player took this object in hand (Interaction.SetGrabbable).

OnDrop

csharp
protected internal virtual void OnDrop()

The local player let this object go.

OnUseDown

csharp
protected internal virtual void OnUseDown()

The local player pressed / released the trigger on the grabbable object it holds.

OnUseUp

csharp
protected internal virtual void OnUseUp()

The local player released the trigger on the grabbable object it holds (after OnUseDown).

OnTriggerEnter

csharp
protected internal virtual void OnTriggerEnter(Collider other)

A collider entered this object's trigger collider (Unity's rule: one of the two objects has a rigidbody).

OnTriggerExit

csharp
protected internal virtual void OnTriggerExit(Collider other)

A collider left this object's trigger collider.

OnCollisionEnter

csharp
protected internal virtual void OnCollisionEnter(Collider other)

This object hit another collider: the other collider (OnCollisionEnter(Collision) gives the same collision with the speed of the contact).

csharp
protected internal virtual void OnCollisionEnter(Collision collision)

The same collision, with the speed of the contact and the other body.

OnCollisionExit

csharp
protected internal virtual void OnCollisionExit(Collider other)

This object no longer touches another collider: the other collider.

OnParticleCollision

csharp
protected internal virtual void OnParticleCollision(GameObject other)

Particles hit this object (other: the GameObject of the particle system; its collision module sends collision messages).

OnPlayerTriggerEnter

csharp
protected internal virtual void OnPlayerTriggerEnter()

The local player entered / left this trigger (its own body: each client tells its own player).

OnPlayerTriggerExit

csharp
protected internal virtual void OnPlayerTriggerExit()

The local player left this trigger (its own body: each client tells its own player).

OnOwnershipChanged

csharp
protected internal virtual void OnOwnershipChanged(int newOwnerId)

The object of the script has a new owner (Networking.GetOwner).

OnOwnershipRequest

csharp
protected internal virtual bool OnOwnershipRequest(int requesterId)

A player (the local one, or another through the owner) wants to own the object: false refuses.

OnPlayerJoined

csharp
protected internal virtual void OnPlayerJoined(int playerId)

Another player entered the room (on the server: any player), with its id.

OnPlayerLeft

csharp
protected internal virtual void OnPlayerLeft(int playerId)

A player left the room, with its id.

OnMasterChanged

csharp
protected internal virtual void OnMasterChanged(int masterId)

The master of the room changed (the previous one left).

OnLanguageChanged

csharp
protected internal virtual void OnLanguageChanged(string language)

The player changed the language of its client (Player.language).

OnPlayerRespawn

csharp
protected internal virtual void OnPlayerRespawn()

The local player respawned: it fell under the world (NWWorldRef respawn height), or a script called Player.Respawn.

OnSerialize

csharp
protected internal virtual void OnSerialize(NetWriter writer)

The owner writes the synced state of the script (after RequestSerialization, once per frame at most).

OnDeserialize

csharp
protected internal virtual void OnDeserialize(NetReader reader)

The other players read the synced state the owner wrote (also a player who arrives).

OnPostSerialization

csharp
protected internal virtual void OnPostSerialization(bool sent)

The synced state asked by RequestSerialization was sent (true), or not (false: not the owner).

OnNetworkEvent

csharp
protected internal virtual void OnNetworkEvent(string name, NetReader arguments, int senderId)

A network event sent by SendNetworkEvent (senderId: the player who sent it).

RequestSerialization

csharp
public void RequestSerialization(bool reliable = true)

Sends the synced state of the script (OnSerialize) at the end of the frame, if the local player owns the object. reliable false: as often as wanted, the latest wins (continuous state).

SendNetworkEvent

csharp
public void SendNetworkEvent(NetworkEventTarget target, string name, NetWriter arguments = null)

Runs OnNetworkEvent(name, arguments) of this script on the players of the target.

SendNetworkEventToPlayer

csharp
public void SendNetworkEventToPlayer(int playerId, string name, NetWriter arguments = null)

Runs OnNetworkEvent(name, arguments) of this script on one player.

RunAfter

csharp
public Coroutine RunAfter(float seconds, Action action)

Runs action after this many seconds (world time), as long as the script lives.

RunAfterFrames

csharp
public Coroutine RunAfterFrames(int frames, Action action)

Runs action after this many frames (1: the next frame).

StartCoroutine

csharp
public Coroutine StartCoroutine(IEnumerator routine)

Starts a coroutine owned by this script (stopped when the script is destroyed).

StopCoroutine

csharp
public void StopCoroutine(Coroutine coroutine)

Stops a coroutine of this script (null does nothing); its finally blocks run.

StopAllCoroutines

csharp
public void StopAllCoroutines()

Stops every coroutine of this script; their finally blocks run.

print

csharp
public static void print(object message)

Writes message to the log, as Debug.Log.