public static MoveDouble Create(Property p, Vector3 o, Axis3 a, Vector3Callback c) { GameObject g = null; switch (a) { case Axis3.X: g = GameObject.Instantiate(x.Object); break; case Axis3.Y: g = GameObject.Instantiate(y.Object); break; case Axis3.Z: g = GameObject.Instantiate(z.Object); break; default: return(null); } MoveDouble m = g.AddComponent <MoveDouble>(); m.property = p; m.DragEvent += c; return(m); }
public static Move Create(Property p, Vector3 o, Vector3Callback c) { Move m = null; if (p.mdp.Count > 0) { m = p.mdp.Dequeue(); m.gameObject.SetActive(true); m.transform.position = o; } else { m = new GameObject("Position Handle").AddComponent <Move>(); m.transform.position = o; m.transform.SetParent(Parent); Vector3Callback _c = (v) => { m.transform.position = v; if (m.callback != null) { m.callback(v); } }; for (int i = 0; i < 3; i++) { MoveSingle s = MoveSingle.Create(p, o, (Axis3)i, null); s.transform.SetParent(m.transform, false); s.DragEvent += (v) => { _c(v); s.transform.position = v; }; } for (int i = 0; i < 3; i++) { MoveDouble d = MoveDouble.Create(p, o, (Axis3)i, null); d.transform.SetParent(m.transform, false); d.DragEvent += (v) => { _c(v); d.transform.position = v; }; } } m.callback = c; m.property = p; p.mep.Add(m); return(m); }