private GameObject _instantiateObject(string primitive, string uid) { if (NegativeSpaceCenter == null) { NegativeSpaceCenter = GameObject.Find("NegativeSpaceCenter"); } GameObject o; if (primitive == "cube") { o = GameObject.CreatePrimitive(PrimitiveType.Cube); } else if (primitive == "sphere") { o = GameObject.CreatePrimitive(PrimitiveType.Sphere); } else { o = new GameObject(); } o.transform.parent = NegativeSpaceCenter.transform; o.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f); o.transform.localPosition = Vector3.zero; o.transform.localRotation = Quaternion.identity; o.name = uid; NegativeSpaceObject ns = o.AddComponent <NegativeSpaceObject>(); ns.name = uid; _negativeSpaceObjects.Add(uid, o); return(o); }
private void _debug_negativeSpaceConnections() { if (Input.GetMouseButtonDown(0)) { // if left button pressed... Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Debug.DrawRay(ray.origin, ray.direction); if (Physics.Raycast(ray, out hit)) { NegativeSpaceObject o = hit.transform.gameObject.GetComponent <NegativeSpaceObject>(); if (o != null) { if (o.lockStatus == LockType.NotLocked) { o.lockStatus = LockType.Local; _rpc.lockObject(o.name); } else if (o.lockStatus == LockType.Local) { o.lockStatus = LockType.NotLocked; _rpc.unlockObject(o.name); } } else { _log.WriteLine(this, "Object is Null"); } } } }
private void _syncNegativeSpaceObjects() { foreach (GameObject o in _negativeSpaceObjects.Values) { NegativeSpaceObject nso = o.GetComponent <NegativeSpaceObject>(); if (nso.lockStatus == LockType.Local) { _rpc.updateNegativeSpaceObject(nso.name, o.transform.localPosition, o.transform.localRotation); } } }