using UnityEngine;
using TNet;
public class Test2 : MonoBehaviour
{
void Start ()
{
// Example A: Executing a single line of code:
RuntimeCode.Execute(@"Debug.Log(typeof(TNet.TNManager));");
// Example B: Compiling a MonoBehaviour from source at runtime:
var text = @"
using UnityEngine;
public class Test3 : MonoBehaviour
{
void Start () { InvokeRepeating(""LogTest"", 1f, 1f); }
void LogTest () { Debug.Log(""Test""); }
}";
RuntimeCode.Add(text);
var type = TypeExtensions.GetType("Test3");
if (type != null) gameObject.AddComponent(type);
else Debug.LogError("Can't find the type");
}
}