As of TNet 3, it's no longer necessary to call TNManager.AddRCCs<T>(), and the syntax of RCCs changed. They can be called by name, just like RFCs (the ID is no longer needed). Instantiation is done via TNManager.Instantiate, or TNBehaviour's Instantiate() functions (there for convenience).
Examining the ExampleCreate.cs script shows both steps needed -- creating the RFC and instantiating an object. As such, this topic is now obsolete.
using UnityEngine;
using TNet;
public class ExampleCreate : MonoBehaviour
{
/// <summary>
/// Create a new object above the clicked position
/// </summary>
void OnClick ()
{
// Object's position will be up in the air so that it can fall down
Vector3 pos = TouchHandler.worldPos + Vector3.up * 3f;
// Object's rotation is completely random
Quaternion rot = Quaternion.Euler(Random.value * 180f, Random.value * 180f, Random.value * 180f);
// Object's color is completely random
Color color
= new Color
(Random
.value, Random
.value, Random
.value, 1f
);
// Create the object using a custom creation function defined below
TNManager.Instantiate("ColoredObject", "Created Cube", true, pos, rot, color);
}
/// <summary>
/// RCCs (Remote Creation Calls) allow you to pass arbitrary amount of parameters to the object you are creating.
/// TNManager will call this function, passing a prefab to it that you should then instantiate.
/// </summary>
[RCC]
static GameObject ColoredObject (GameObject prefab, Vector3 pos, Quaternion rot, Color c)
{
// Instantiate the prefab
GameObject go = Object.Instantiate(prefab) as GameObject;
// Set the position and rotation based on the passed values
Transform t = go.transform;
t.position = pos;
t.rotation = rot;
// Set the renderer's color as well
go.GetComponentInChildren<Renderer>().material.color = c;
return go;
}
}