/// <summary>Generates a branch on the native side and returns a <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/> struct that contains a reference to it.</summary> /// <param name="userID">A unique id to help identify this particular branch. For instance, this could be an InstanceID to a [UnityEngine.Object](https://docs.unity3d.com/ScriptReference/Object.html)</param> /// <param name="children">The child nodes that are children of this branch. A branch may not have duplicate children, contain itself or contain a <see cref="RealtimeCSG.Foundation.CSGTree"/>.</param> /// <returns>A new <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>. May be an invalid node if it failed to create it.</returns> public static CSGTreeBranch Create(Int32 userID, params CSGTreeNode[] children) { int branchNodeID; if (!GenerateBranch(userID, out branchNodeID)) { return new CSGTreeBranch() { branchNodeID = 0 } } ; if (children != null && children.Length > 0) { if (!CSGTreeNode.SetChildNodes(branchNodeID, children)) { CSGTreeNode.DestroyNode(branchNodeID); return(new CSGTreeBranch() { branchNodeID = 0 }); } } return(new CSGTreeBranch() { branchNodeID = branchNodeID }); }
/// <summary>Generates a branch on the native side and returns a <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/> struct that contains a reference to it.</summary> /// <param name="userID">A unique id to help identify this particular branch. For instance, this could be an InstanceID to a [UnityEngine.Object](https://docs.unity3d.com/ScriptReference/Object.html)</param> /// <param name="children">The child nodes that are children of this branch. A branch may not have duplicate children, contain itself or contain a <see cref="RealtimeCSG.Foundation.CSGTree"/>.</param> /// <returns>A new <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>. May be an invalid node if it failed to create it.</returns> public static CSGTreeBranch Create(Int32 userID = 0, CSGOperationType operation = CSGOperationType.Additive, params CSGTreeNode[] children) { int branchNodeID; if (!GenerateBranch(userID, out branchNodeID)) { return new CSGTreeBranch() { branchNodeID = 0 } } ; if (children != null && children.Length > 0) { if (operation != CSGOperationType.Additive) { SetBranchOperationType(userID, operation); } if (!CSGTreeNode.SetChildNodes(branchNodeID, children)) { CSGTreeNode.DestroyNode(branchNodeID); return(new CSGTreeBranch() { branchNodeID = 0 }); } } return(new CSGTreeBranch() { branchNodeID = branchNodeID }); }