Cluster Creator Kit Script Reference
    Preparing search index...

    Interface UnityComponent

    The handle of the Unity component attached to an object.

    This handle can be obtained by the following APIs.

    If the instance is obtained by ClusterScript.getUnityComponent or SubNode.getUnityComponent, operations on the handle will modify the appearance and behavior of the item, visible to all players.

    If the instance is obtained by PlayerLocalObject.getUnityComponent, operations on the handle will modify the appearance and behavior of the item, visible only to that player.

    These APIs support the same list of component names. The following is the list of available type names for the getUnityComponent method.

    • "AimConstraint"
    • "Animator"
    • "AudioSource"
    • "BoxCollider"
    • "Button"
    • "Camera"
    • "Canvas"
    • "CanvasGroup"
    • "CapsuleCollider"
    • "CharacterJoint"
    • "ConfigurableJoint"
    • "Dropdown"
    • "FixedJoint"
    • "GridLayoutGroup"
    • "HingeJoint"
    • "HorizontalLayoutGroup"
    • "Image"
    • "InputField"
    • "LayoutElement"
    • "Light"
    • "LineRenderer"
    • "LookAtConstraint"
    • "Mask"
    • "MeshCollider"
    • "MeshRenderer"
    • "Outline"
    • "ParentConstraint"
    • "ParticleSystem"
    • "PlayableDirector"
    • "PositionConstraint"
    • "PostProcessVolume"
    • "RawImage"
    • "RectTransform"
    • "Rigidbody"
    • "RotationConstraint"
    • "ScaleConstraint"
    • "Scrollbar"
    • "ScrollRect"
    • "Shadow"
    • "SkinnedMeshRenderer"
    • "Slider"
    • "SphereCollider"
    • "SpringJoint"
    • "Text"
    • "TextMesh"
    • "TextMeshPro"
    • "TextMeshProUGUI"
    • "TMP_Dropdown"
    • "TMP_InputField"
    • "Toggle"
    • "ToggleGroup"
    • "TrailRenderer"
    • "Transform"
    • "VerticalLayoutGroup"
    • "VideoPlayer"
    • "WheelCollider"
    interface UnityComponent {
        unityProp: UnityComponentPropertyProxy;
        onClick(callback: (isDown: boolean) => void): void;
        play(): void;
        setBool(id: string, value: boolean): void;
        setFloat(id: string, value: number): void;
        setInteger(id: string, value: number): void;
        setTrigger(id: string): void;
        stop(): void;
    }
    Index

    Properties

    unityProp: UnityComponentPropertyProxy

    A handle to access properties of the Unity component.

    This API requires the exact name of the property as defined in the Unity component. The property name shown in the Unity Editor may differ from the actual property name. Please refer to the Unity API reference for details.

    The properties that can be accessed with unityProp must be one of the following data types: bool, int, float, double, string, Vector2, Vector3, Vector4, Quaternion, Color, Rect, or a derived type of Enum. If you attempt to access a property of a different data type, null will be returned when getting the property, and an exception will be thrown when setting the property.

    Enum types are represented as int values. Similarly, when setting a property of type Enum, specify an int value. Please refer to the Unity API reference for the correspondence between Enum values and their internal int representation.

    When setting property values from this handle, changes are applied after the script execution completes. If you get a property value immediately after setting it within the same callback, you will not receive the updated value.

    In Player Script, properties updated via this API are reflected only in the player running the script.

    // An example for Player Script to set the property of the component in PlayerLocalObject
    let imageObject = _.playerLocalObject("ImageObject");
    let image = imageObject.getUnityComponent("Image");
    image.unityProp.color = new Color(1, 0, 0, 1);

    let textObject = _.playerLocalObject("TextObject");
    let textComponent = textObject.getUnityComponent("Text");
    textComponent.unityProp.text = "Hello, World!";

    In Player Script, all properties with supported data types can be read and written.

    In Scriptable Item, property values set via this API are synchronized over the network. Please be aware that updates may not be reflected immediately, and no interpolation is applied to the values.

    // An example for Scriptable Item to set the property of the component in SubNode
    let node = $.subNode("Cube");
    let meshRenderer = node.getUnityComponent("MeshRenderer");
    meshRenderer.unityProp.receiveShadows = false;

    let transform = node.getUnityComponent("Transform");
    transform.unityProp.localScale = new Vector3(2, 2, 2);

    In Scriptable Item, the following scenarios will result in undefined behavior. These operations may cause the item state to desynchronize between players.

    • When this API and other Cluster Script APIs both update the same property internally
      • For example, SubNode.setPosition internally updates Transform.localPosition, so updating Transform.localPosition with this API while also using setPosition will result in undefined behavior
    • When this API and gimmick components both update the same property internally
    • When this API and Unity features (e.g., Animator) both update the same property
    • When updating a property with this API triggers changes in the internal state of a Unity component

    To avoid undefined behavior:

    • Do not control properties updated by this API using Animator or other components
    • Prefer using dedicated APIs when available over this API

    For example, use ClusterScript.setPosition to change an item's position instead of updating Transform.localPosition with this API.

    In Scriptable Item, the properties accessible via this API are restricted to ensure proper synchronization between players. The following properties can be read and written for each component type:

    • AimConstraint
      • enabled
      • aimVector
      • constraintActive
      • rotationAtRest
      • rotationAxis
      • rotationOffset
      • upVector
      • weight
      • worldUpVector
    • Animator
      • enabled
    • AudioSource
      • enabled
      • bypassEffects
      • bypassListenerEffects
      • bypassReverbZones
      • dopplerLevel
      • loop
      • maxDistance
      • minDistance
      • mute
      • panStereo
      • pitch
      • playOnAwake
      • priority
      • spatialize
      • spatializePostEffects
      • volume
    • BoxCollider
      • enabled
      • center
      • isTrigger
      • size
    • Button
      • enabled
      • interactable
      • transition
    • Camera
      • enabled
      • allowHDR
      • allowMSAA
      • anamorphism
      • aperture
      • backgroundColor
      • barrelClipping
      • bladeCount
      • curvature
      • depth
      • farClipPlane
      • fieldOfView
      • focalLength
      • focusDistance
      • forceIntoRenderTexture
      • iso
      • lensShift
      • nearClipPlane
      • orthographic
      • orthographicSize
      • rect
      • sensorSize
      • shutterSpeed
      • stereoConvergence
      • stereoSeparation
      • useOcclusionCulling
      • usePhysicalProperties
    • Canvas
      • enabled
      • normalizedSortingGridSize
      • overridePixelPerfect
      • overrideSorting
      • pixelPerfect
      • planeDistance
    • CanvasGroup
      • enabled
      • alpha
      • blocksRaycasts
      • ignoreParentGroups
      • interactable
    • CapsuleCollider
      • enabled
      • center
      • height
      • isTrigger
      • radius
    • CharacterJoint
      • enableProjection
      • projectionAngle
      • projectionDistance
    • ConfigurableJoint
      • configuredInWorldSpace
      • enableCollision
      • enablePreprocessing
      • projectionAngle
      • projectionDistance
      • swapBodies
      • targetAngularVelocity
      • targetPosition
      • targetRotation
      • targetVelocity
    • Dropdown
      • enabled
      • alphaFadeSpeed
      • interactable
      • transition
      • value
    • FixedJoint
      • breakForce
      • breakTorque
      • enableCollision
      • enablePreprocessing
    • GridLayoutGroup
      • enabled
      • cellSize
      • childAlignment
      • constraint
      • constraintCount
      • spacing
      • startAxis
      • startCorner
    • HingeJoint
      • breakForce
      • breakTorque
      • enableCollision
      • enablePreprocessing
      • useLimits
      • useMotor
      • useSpring
    • HorizontalLayoutGroup
      • enabled
      • childAlignment
      • childControlHeight
      • childControlWidth
      • childForceExpandHeight
      • childForceExpandWidth
      • childScaleHeight
      • childScaleWidth
      • reverseArrangement
      • spacing
    • Image
      • enabled
      • color
      • fillAmount
      • fillCenter
      • fillClockwise
      • fillMethod
      • fillOrigin
      • maskable
      • pixelsPerUnitMultiplier
      • preserveAspect
      • raycastPadding
      • raycastTarget
      • type
      • useSpriteMesh
    • InputField
      • enabled
      • caretBlinkRate
      • caretWidth
      • characterLimit
      • characterValidation
      • contentType
      • customCaretColor
      • interactable
      • lineType
      • readOnly
      • selectionColor
      • text
      • transition
    • LayoutElement
      • enabled
      • flexibleHeight
      • flexibleWidth
      • ignoreLayout
      • layoutPriority
      • minHeight
      • minWidth
      • preferredHeight
      • preferredWidth
    • Light
      • enabled
      • bounceIntensity
      • color
      • colorTemperature
      • intensity
      • range
      • shadowBias
      • shadowNearPlane
      • shadowNormalBias
      • shadowStrength
      • spotAngle
    • LineRenderer
      • enabled
      • loop
      • meshLodSelectionBias
      • receiveShadows
      • rendererPriority
      • sortingOrder
      • useWorldSpace
      • widthMultiplier
    • LookAtConstraint
      • enabled
      • constraintActive
      • roll
      • rotationAtRest
      • rotationOffset
      • useUpObject
      • weight
    • Mask
      • enabled
      • showMaskGraphic
    • MeshCollider
      • enabled
      • convex
      • isTrigger
    • MeshRenderer
      • enabled
      • meshLodSelectionBias
      • receiveShadows
      • rendererPriority
      • sortingOrder
    • Outline
      • enabled
      • effectColor
      • effectDistance
      • useGraphicAlpha
    • ParentConstraint
      • enabled
      • constraintActive
      • rotationAtRest
      • rotationAxis
      • translationAtRest
      • translationAxis
      • weight
    • PlayableDirector
      • enabled
    • PositionConstraint
      • enabled
      • constraintActive
      • translationAtRest
      • translationAxis
      • translationOffset
      • weight
    • PostProcessVolume
      • enabled
      • blendDistance
      • isGlobal
      • priority
      • weight
    • RawImage
      • enabled
      • color
      • maskable
      • raycastPadding
      • raycastTarget
      • uvRect
    • RectTransform
      • anchorMax
      • anchorMin
      • anchoredPosition
      • localPosition
      • localRotation
      • localScale
      • pivot
      • rect
      • sizeDelta
    • Rigidbody
      • angularDamping
      • centerOfMass
      • inertiaTensor
      • inertiaTensorRotation
      • isKinematic
      • linearDamping
      • mass
      • useGravity
    • RotationConstraint
      • enabled
      • constraintActive
      • rotationAtRest
      • rotationAxis
      • rotationOffset
      • weight
    • ScaleConstraint
      • enabled
      • constraintActive
      • scaleAtRest
      • scaleOffset
      • scalingAxis
      • weight
    • ScrollRect
      • enabled
      • decelerationRate
      • elasticity
      • horizontal
      • inertia
      • movementType
      • scrollSensitivity
      • vertical
    • Scrollbar
      • enabled
      • direction
      • interactable
      • numberOfSteps
      • size
      • transition
      • value
    • Shadow
      • enabled
      • effectColor
      • effectDistance
      • useGraphicAlpha
    • SkinnedMeshRenderer
      • enabled
      • meshLodSelectionBias
      • receiveShadows
      • rendererPriority
      • skinnedMotionVectors
      • sortingOrder
      • updateWhenOffscreen
    • Slider
      • enabled
      • direction
      • interactable
      • maxValue
      • minValue
      • transition
      • value
      • wholeNumbers
    • SphereCollider
      • enabled
      • center
      • isTrigger
      • radius
    • SpringJoint
      • breakForce
      • breakTorque
      • damper
      • enableCollision
      • enablePreprocessing
      • maxDistance
      • minDistance
      • spring
      • tolerance
    • TMP_Dropdown
      • enabled
      • alphaFadeSpeed
      • interactable
      • transition
      • value
    • TMP_InputField
      • enabled
      • caretBlinkRate
      • caretColor
      • caretWidth
      • characterLimit
      • characterValidation
      • contentType
      • customCaretColor
      • interactable
      • lineLimit
      • onFocusSelectAll
      • pointSize
      • readOnly
      • richText
      • selectionColor
      • text
      • transition
    • Text
      • enabled
      • color
      • maskable
      • text
      • raycastPadding
      • raycastTarget
    • TextMesh
      • characterSize
      • fontSize
      • lineSpacing
      • offsetZ
      • richText
      • tabSize
      • text
    • TextMeshPro
      • enabled
      • color
      • enableAutoSizing
      • enableCulling
      • extraPadding
      • fontSize
      • fontSizeMax
      • fontSizeMin
      • fontStyle
      • lineSpacing
      • margin
      • maskable
      • overflowMode
      • overrideColorTags
      • pageToDisplay
      • parseCtrlCharacters
      • raycastTarget
      • richText
      • text
      • textWrappingMode
      • vertexBufferAutoSizeReduction
    • TextMeshProUGUI
      • enabled
      • color
      • enableAutoSizing
      • enableCulling
      • extraPadding
      • fontSize
      • fontSizeMax
      • fontSizeMin
      • fontStyle
      • lineSpacing
      • margin
      • maskable
      • overflowMode
      • overrideColorTags
      • pageToDisplay
      • parseCtrlCharacters
      • raycastTarget
      • richText
      • text
      • textWrappingMode
      • vertexBufferAutoSizeReduction
    • Toggle
      • enabled
      • interactable
      • isOn
      • transition
    • ToggleGroup
      • enabled
      • allowSwitchOff
    • TrailRenderer
      • enabled
      • autodestruct
      • emitting
      • meshLodSelectionBias
      • minVertexDistance
      • receiveShadows
      • rendererPriority
      • sortingOrder
      • time
      • widthMultiplier
    • Transform
      • localPosition
      • localRotation
      • localScale
    • VerticalLayoutGroup
      • enabled
      • childAlignment
      • childControlHeight
      • childControlWidth
      • childForceExpandHeight
      • childForceExpandWidth
      • childScaleHeight
      • childScaleWidth
      • reverseArrangement
      • spacing
    • VideoPlayer
      • enabled
      • isLooping
      • playOnAwake
      • playbackSpeed
      • sendFrameReadyEvents
      • skipOnDrop
      • targetCameraAlpha
      • waitForFirstFrame
    • WheelCollider
      • enabled
      • center
      • forceAppPointDistance
      • mass
      • radius
      • suspensionDistance
      • wheelDampingRate

    Methods

    • Registers a callback function to be called when a Button in a Player Local UI is interacted with.

      The component should be a Button and should be obtained by PlayerLocalObject.getUnityComponent. If the component is not a Button, or the instance is obtained by ClusterScript.getUnityComponent or SubNode.getUnityComponent, an error will occur.

      If the same callback is registered multiple times for a Button component, only the last registration will take effect.

      The callback will be called with isDown = true when pressed, and called again with isDown = false when the button is released. This callback is not necessarily called with isDown = false after being called with isDown = true. For example, if you hold down the button, move the pointer outside of the button, and then release it, the isDown = false callback will not be triggered.

      Parameters

      • callback: (isDown: boolean) => void

        method that is called when the button is pressed or released.

      Returns void

    • Plays the component if the handled component is PlayableDirector, AudioSource, ParticleSystem, or VideoPlayer.

      An error will occur for other components.

      If the instance is obtained by ClusterScript.getUnityComponent by SubNode.getUnityComponent and the handled component is PlayableDirector, AudioSource, its time will look same for all players. The beginning of the playback may be skipped.

      When play() is called for already playing component, the component will stop and restart playing.

      For ParticleSystem, this method also plays particles attached in children objects. If both a parent and child object have ParticleSystem, please execute play() or stop() on the particles of the parent only. If play() or stop() is called for multiple ParticleSystems in a parent-child relationship, they may not play correctly.

      For VideoPlayer, it is recommended to specify Video Clip for Source and Material Override for Render Mode. If Source is set to Video Clip, the playback time will look same for all players. The beginning of the playback may be skipped. Also, depending on the size of the video and the encoding method, it may take some time for playback to start.

      If Source is URL, there will be a large delay until the playback actually starts. Also, the playback start timing and playback time will not be consistent for each player.

      If the rendering result of VideoPlayer is applied to Render Texture, the rendering state when not playing will change depending on the OS and texture settings. Consider to hide the texture when VideoPlayer is not playing.

      Returns void

    • Sets Bool parameter value of the AnimatorController, if the handled component is Animator. An error will occur for other components.

      This method does nothing if the parameter does not exist, or if it is not Bool.

      Parameters

      • id: string

        Name of the parameter

      • value: boolean

        The value to set

      Returns void

    • Sets Float parameter value of the AnimatorController, if the handled component is Animator. An error will occur for other components.

      This method does nothing if the parameter does not exist, or if it is not Float.

      Parameters

      • id: string

        Name of the parameter

      • value: number

        The value to set

      Returns void

    • Sets Integer parameter value of the AnimatorController, if the handled component is Animator. An error will occur for other components.

      This method does nothing if the parameter does not exist, or if it is not Integer.

      Parameters

      • id: string

        Name of the parameter

      • value: number

        The value to set

      Returns void

    • Sets Trigger of the AnimatorController, if the handled component is Animator. An error will occur for other components.

      This method does nothing if the parameter does not exist, or if it is not Trigger.

      Parameters

      • id: string

        The name of the parameter

      Returns void

    • Stops the component playback if the handled component is PlayableDirector, AudioSource, ParticleSystem, or VideoPlayer.

      An error will occur for other components.

      Playback time will be reset when stop() is called for PlayableDirector and VideoPlayer.

      For ParticleSystem, this method also stops particles attached in children objects. If both a parent and child object have ParticleSystem, please execute play() or stop() on the particles of the parent only. If play() or stop() is called for multiple ParticleSystems in a parent-child relationship, they may not play correctly.

      Returns void