public CanvasSlotCommand(FxCanvasSlot obj, Exporter exporter) { ObjectType = CommandTypeCanvasSlot; //---------------- canvasID = exporter.GetObject(obj.canvas).ObjectID; channelName = obj.names[obj.channelName]; }
private void DrawNodeLinkLine(FxCanvasSlot slot) { if (slot.canvas == null) { return; } var pointA = slot.gameObject.transform.position; var pointB = slot.canvas.gameObject.transform.position; var dir2 = (pointB - pointA).normalized; var pointC = (pointA + pointB) * 0.5f; var pointD = pointC - dir2 * 1.2f; //var dir = Vector3.Cross(pointA, pointB); pointA.z = 0; pointB.z = 0; var dir = pointB - pointA; dir = new Vector3(dir.y, -dir.x, 0); dir = dir.normalized; //var dir2 = (pointB - pointA).normalized; Gizmos.DrawLine(pointD, pointC + dir); Gizmos.DrawLine(pointD, pointC - dir); Gizmos.DrawLine(pointA, pointB); }
public static void OnConnectNodes() { FxCanvasSlot slot = null; FxCanvasObject node = null; foreach (var gameObject in Selection.gameObjects) { var slotobj = gameObject.GetComponentInChildren <FxCanvasSlot>(); if (slotobj != null && slotobj.canvas == null) { slot = slotobj; break; } } if (slot == null) { return; } List <FxCanvasObject> cs = new List <FxCanvasObject>(); var pc = slot.gameObject.GetComponentsInChildren <FxCanvasObject>(); foreach (var p in pc) { cs.Add(p); } pc = slot.gameObject.GetComponentsInParent <FxCanvasObject>(); foreach (var p in pc) { cs.Add(p); } //--------- foreach (var gameObject in Selection.gameObjects) { //----------node------------- var nodeobj = gameObject.GetComponentInChildren <FxCanvasObject>(); if (nodeobj != null && cs.IndexOf(nodeobj) < 0) { node = nodeobj; break; } nodeobj = gameObject.GetComponentInParent <FxCanvasObject>(); if (nodeobj != null && cs.IndexOf(nodeobj) < 0) { node = nodeobj; break; } } Debug.Log("node:" + node + ",slot:" + slot); if (slot == null || node == null) { Debug.LogWarning("选择的内容中找不到能够链接的对象!!"); } else { slot.canvas = node; } }