Example #1
0
        /// <summary>Generates a tree on the native side and returns a <see cref="RealtimeCSG.Foundation.CSGTree"/> struct that contains a reference to it.</summary>
        /// <param name="userID">A unique id to help identify this particular tree. 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 tree. A tree may not have duplicate children, contain itself or contain a <see cref="RealtimeCSG.Foundation.CSGTree"/>.</param>
        /// <returns>A new <see cref="RealtimeCSG.Foundation.CSGTree"/>. May be an invalid node if it failed to create it.</returns>
        public static CSGTree Create(Int32 userID, params CSGTreeNode[] children)
        {
            int treeNodeID;

            if (!GenerateTree(userID, out treeNodeID))
            {
                return new CSGTree()
                       {
                           treeNodeID = 0
                       }
            }
            ;
            if (children != null && children.Length > 0)
            {
                if (!CSGTreeNode.InsertChildNodeRange(treeNodeID, 0, children))
                {
                    CSGTreeNode.DestroyNode(treeNodeID);
                    return(new CSGTree()
                    {
                        treeNodeID = 0
                    });
                }
            }
            return(new CSGTree()
            {
                treeNodeID = treeNodeID
            });
        }
 /// <summary>Inserts the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>s of an array into the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/> at the specified index.</summary>
 /// <param name="index">The zero-based index at which the new <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>s should be inserted.</param>
 /// <param name="array">The array whose <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>s should be inserted into the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>. The array itself cannot be null.</param>
 /// <returns><b>true</b> on success, <b>false</b> on failure</returns>
 public bool InsertRange(int index, CSGTreeNode[] array)
 {
     if (array == null)
     {
         throw new ArgumentNullException("array");
     }
     return(CSGTreeNode.InsertChildNodeRange(branchNodeID, index, array));
 }
 /// <summary>Adds the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>s of the specified array to the end of the  <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</summary>
 /// <param name="array">The array whose <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>s should be added to the end of the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>. The array itself cannot be null.</param>
 /// <returns><b>true</b> on success, <b>false</b> on failure</returns>
 public bool AddRange(CSGTreeNode[] array)
 {
     if (array == null)
     {
         throw new ArgumentNullException("array");
     }
     return(CSGTreeNode.InsertChildNodeRange(branchNodeID, Count, array));
 }