private void SpawnCharacter(TrackableHit hit) { Vector3 lookRotation = Quaternion.LookRotation(firstPersonCamera.transform.position - hit.Point).eulerAngles; lookRotation.x = 0f; lookRotation.z = 0f; // Spawned characted needs to face the camera Quaternion spawnRotation = Quaternion.Euler(lookRotation); // Create an anchor to allow ARCore to track the hitpoint as understanding of the physical // world evolves. Anchor anchor = Session.CreateAnchor(hit.Point, Quaternion.identity); // Spawn character from prefab and attach it to anchor GameObject akiraGO = Instantiate(akiraPrefab, hit.Point, spawnRotation, anchor.transform); // Save reference to character akira = akiraGO.GetComponent <Akira>(); // Use a plane attachment component to maintain Akira's y-offset from the plane // (occurs after anchor updates). akiraGO.AddComponent <PlaneAttachment>().Attach(hit.Plane); // Print message on screen _ShowAndroidToastMessage("Created character!"); }
//public class gen0 : akira.Match.Instance //{ //} //protected Instance GenerateInstance(Context ctx, XElement node) //{ // string code = GenerateClass(ctx, node); // // var a = Akira.AssemblyFromCode(code); // Assembly assembly = Assembly.LoadFile(Directory.GetCurrentDirectory() + "/gen0.dll"); // Type t = assembly.GetTypes()[0]; // if (t.IsSubclassOf(typeof(Instance))) // { // var o = assembly.CreateInstance(t.FullName); // Instance i = o as Instance; // i.left = node.Elements().ElementAt(0); // i.right = node.Elements().ElementAt(1); // return i; // } // return null; //} protected Rule GenerateInstance(Context ctx, XElement node) { string code = GenerateClass(ctx, node); var a = Akira.AssemblyFromCode(code); // Assembly assembly = Assembly.LoadFile(Directory.GetCurrentDirectory() + "/gen0.dll"); Type t = a.GetTypes()[0]; var o = a.CreateInstance(t.FullName); t.GetField("left").SetValue(o, node.Elements().ElementAt(0)); t.GetField("right").SetValue(o, node.Elements().ElementAt(1)); return((Rule)o); }