UnityService
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.
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 fromNewGameObject/CreatePrimitive/FindGameObject/FindAnchorGameObjectand passed back into the mutators. Do not assume it is aUnityEngine.GameObjecton the calling side. - Transforms are flat
float[].GetTransform/SetTranformexchange transform data as packed arrays — 16-element matrices, or 3/4-element vectors/quaternions — selected byTransformTypes. - Positions are in meters; rotations are Unity quaternions.
Members
| Member | Type | Description |
|---|---|---|
| Configuration | ||
Prefabs | GameObject[] | prefabs available to instantiate by name |
DefaultMaterial | Material | material applied when none is specified |
MainCamera | object (get) | handle to the scene's main camera |
| Scene graph | ||
NewGameObject(string name) | object | create an empty GameObject; returns its handle |
CreatePrimitive(...) | object | create a primitive (positions in meters); see below |
Destroy(object gameObject) | void | destroy a GameObject |
ClearInstances() | void | destroy all instances created through this service |
SetParent(object gameObject, object parent) | void | re-parent a GameObject |
FindGameObject(string name) | object | find a GameObject by name |
FindAnchorGameObject(string anchorId) | object | find the GameObject for a spatial anchor |
GetName / SetName | string / void | read / set a GameObject's name |
IsDestroyed(object obj) | bool | whether the handle's object has been destroyed |
GetActive / SetActive | bool | read / set active state |
SetRendererEnable(object, bool) | void | enable/disable the renderer |
Transforms (flat float[], meters) | ||
GetTransform(object, TransformTypes) | float[] | read a transform as a packed array |
SetTranform(object, TransformTypes, float[]) | void | apply a packed transform (name spelled SetTranform) |
SetCameraProject(float[] projectionMatix) | void | set the camera projection matrix (16-element) |
| Materials | ||
SetMaterialTexture(...) | void | set a texture from JPG bytes |
SetMaterialField<T>(object, string, T, bool) | void | set an arbitrary material field |
SetMaterialColor / GetMaterialColor | void / AR51.Core.Color | set / 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
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).
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
ServiceManager— the singleton host that stands up the service layer this handler runs onRenderService— application-level scene rendering controlGameService— application-level game/scene lifecycle- Class index — all Unity SDK types