Click or drag to resize

ASLHelperInstantiateASLObject Method (PrimitiveType, Vector3, Quaternion, String, String, ASLObjectASLGameObjectCreatedCallback, ASLObjectClaimCancelledRecoveryCallback, ASLObjectFloatCallback)

Create an ASL Object

Namespace:  ASL
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntax
public static void InstantiateASLObject(
	PrimitiveType _type,
	Vector3 _position,
	Quaternion _rotation,
	string _parentID,
	string _componentAssemblyQualifiedName,
	ASLObjectASLGameObjectCreatedCallback _aslGameObjectCreatedCallbackInfo,
	ASLObjectClaimCancelledRecoveryCallback _aslClaimCancelledRecoveryFunctionInfo,
	ASLObjectFloatCallback _aslFloatFunctionInfo
)

Parameters

_type
Type: PrimitiveType
The primitive type to be instantiated
_position
Type: Vector3
The position where the object will be instantiated
_rotation
Type: Quaternion
The rotation orientation of the object to be instantiated
_parentID
Type: SystemString
The id or name of the parent object for this instantiated object
_componentAssemblyQualifiedName
Type: SystemString
The full name of the component to be added to this object upon creation.
_aslGameObjectCreatedCallbackInfo
Type: ASLASLObjectASLGameObjectCreatedCallback
This is the function that you want to be called after object creation
_aslClaimCancelledRecoveryFunctionInfo
Type: ASLASLObjectClaimCancelledRecoveryCallback
This is the function that you want to be called whenever a claim is rejected/cancelled
_aslFloatFunctionInfo
Type: ASLASLObjectFloatCallback
This is the name of the function that you want to be executed whenever you use the [!:ASLObject.SendFloatArray(float[])] function.
Examples
void SomeFunction()
{
    //Where gameObject is the parent of the object that is being created here and "MyNamespace.MyClass" is an example of a component you want to add
    ASL.ASLHelper.InstantiateASLObject(PrimitiveType.Cube, new Vector3(0, 0, 0), Quaternion.identity, gameobject.GetComponent<ASL.ASLObject>().m_Id,
    "MyNamespace.MyClass",
    MyUponInstantiationFunction, 
    MyClaimRejectedFunction,
    MySendFloatFunction); 
}
public static void MyUponInstantiationFunction(GameObject _myGameObject)
{
    Debug.Log("Caller-Object ID: " + _myGameObject.GetComponent<ASL.ASLObject>().m_Id);
    _myGameObject.GetComponent<ASL.ASLObject>().SendAndSetClaim(() =>
    {
        float[] myFloats = new float[] { 1.1f, 2.5f, 3.4f, 4.9f };
        _myGameObject.GetComponent<ASL.ASLObject>().SendFloatArray(myFloats);
    });
}

public static void MyClaimRejectedFunction(string _id, int _cancelledCallbacks)
{
   Debug.LogWarning("We are going to cancel " + _cancelledCallbacks +
      " callbacks generated by a claim for object: " + _id + " rather than try to recover.");
} 
public static void MySendFloatFunction(float[] _floats)
{
    for (int i = 0; i<_floats.Length; i++)
    {
        Debug.Log("Value Sent: " + _floats[i]);
    }
}
See Also