Skip to main content

UnityService

sealed class Unity component singleton
public sealed class UnityService : Singleton<UnityService>, IUnityService

Namespace: AR51.Unity.SDK · Implements: Singleton<UnityService> · IUnityService

A remote-control façade over Unity scene operations — create, find, and transform GameObjects, and set materials — driven over the service layer. It is the server-side handler for remote scene commands: a peer issues commands and UnityService applies them to the local Unity scene.

Most app code does not call this directly

UnityService exists to execute scene commands arriving over the service layer. In normal application code you drive the scene with ordinary Unity APIs and use the higher-level services (RenderService, GameService). Reach for UnityService only when implementing or extending the remote scene-command surface.

Remote-operation conventions

Because operations are remote, the surface is intentionally loosely typed:

  • GameObjects are passed as object. A handle is returned from NewGameObject / CreatePrimitive / FindGameObject / FindAnchorGameObject and passed back into the mutators. Do not assume it is a UnityEngine.GameObject on the calling side.
  • Transforms are flat float[]. GetTransform / SetTranform exchange transform data as packed arrays — 16-element matrices, or 3/4-element vectors/quaternions — selected by TransformTypes.
  • Positions are in meters; rotations are Unity quaternions.

Members

MemberTypeDescription
Configuration
PrefabsGameObject[]prefabs available to instantiate by name
DefaultMaterialMaterialmaterial applied when none is specified
MainCameraobject (get)handle to the scene's main camera
Scene graph
NewGameObject(string name)objectcreate an empty GameObject; returns its handle
CreatePrimitive(...)objectcreate a primitive (positions in meters); see below
Destroy(object gameObject)voiddestroy a GameObject
ClearInstances()voiddestroy all instances created through this service
SetParent(object gameObject, object parent)voidre-parent a GameObject
FindGameObject(string name)objectfind a GameObject by name
FindAnchorGameObject(string anchorId)objectfind the GameObject for a spatial anchor
GetName / SetNamestring / voidread / set a GameObject's name
IsDestroyed(object obj)boolwhether the handle's object has been destroyed
GetActive / SetActiveboolread / set active state
SetRendererEnable(object, bool)voidenable/disable the renderer
Transforms (flat float[], meters)
GetTransform(object, TransformTypes)float[]read a transform as a packed array
SetTranform(object, TransformTypes, float[])voidapply a packed transform (name spelled SetTranform)
SetCameraProject(float[] projectionMatix)voidset the camera projection matrix (16-element)
Materials
SetMaterialTexture(...)voidset a texture from JPG bytes
SetMaterialField<T>(object, string, T, bool)voidset an arbitrary material field
SetMaterialColor / GetMaterialColorvoid / AR51.Core.Colorset / read a material color

⚠️ The method name SetTranform (missing an s) is the real signature in this SDK version — preserved here for source-accuracy. The transport spelling in related types similarly varies (e.g. Extrensic).

CreatePrimitive

method
public object CreatePrimitive(
int primitiveType, string name,
AR51.Core.Vector3 position, AR51.Core.Quaternion rotation, AR51.Core.Vector3 scale,
AR51.Core.Color color, object parent);

Create a primitive GameObject in the scene and return its handle. position and scale are in meters; rotation is a Unity quaternion; parent is a GameObject handle (or null).

Returnsobjecta handle to the new GameObject
Internal — not documented

The handler methods of UnityService (the object-typed command surface above) are the server-side implementation of the remote scene-command protocol. The command dispatch, the proto/wire mapping behind the object and float[] parameters, and the handle bookkeeping are internal plumbing and are not documented as a caller-facing API. Use RenderService and GameService for application-level scene control.

See also

Was this page helpful?