/// Helper function to create a top level icon.
        /// The root icon does not have any interaction or icon
        /// ShowRootIcon() initializes the root icon and opens the next level of icons.
        private ConstellationMenuIcon ShowRootIcon()
        {
            ConstellationMenuIcon rootIcon = (ConstellationMenuIcon)Instantiate(menuIconPrefab, transform);

            rootIcon.transform.position = menuCenter;
            rootIcon.transform.rotation = menuOrientation;
            rootIcon.Initialize(this, menuTree.tree.Root, MENU_SCALE);
            ConstellationMenuIcon.ShowMenu(this, menuTree.tree.Root, rootIcon, menuOrientation,
                                           MENU_SCALE);
            rootIcon.SetDummy();
            if (OnMenuOpened != null)
            {
                OnMenuOpened.Invoke();
            }
            return(rootIcon);
        }
        /// Creates and shows a layer of icons below this one.
        /// Returns true if a fade needs to occur.
        public static bool ShowMenu(ConstellationMenuRoot root, AssetTree.Node treeNode, ConstellationMenuIcon parent,
                                    Quaternion orientation, float scale,
                                    IconState initialState = IconState.Shown)
        {
            // Determine how many children are in the sub-menu
            List <AssetTree.Node> childItems = treeNode.children;

            // If this is the end of a menu, invoke the action and return early
            if (childItems.Count == 0)
            {
                root.MakeSelection(parent.menuItem);
                root.CloseAll();
                return(false);
            }
            if (parent.childMenus.Count == childItems.Count)
            {
                // children already exist. just fade them in.
                bool stateChanged = false;
                foreach (ConstellationMenuIcon child in parent.childMenus)
                {
                    if (child.StartFade(initialState))
                    {
                        stateChanged = true;
                    }
                    // Close any children.
                    child.FadeChildren(IconState.Closed);
                }
                return(stateChanged);
            }

            List <Vector3> childPositions;

            float radius;

            if (parent.parentMenu != null)
            {
                radius         = (parent.menuCenter - parent.startPosition).magnitude + ITEM_SPACING;
                childPositions = ArrangeInCircle(childItems.Count, radius,
                                                 parent.angleToRoot - Mathf.PI * .5f,
                                                 parent.angleToRoot + Mathf.PI * .5f,
                                                 ITEM_SPACING);
            }
            else
            {
                // Radius needs to expand when there are more icons
                radius = ITEM_SPACING * Mathf.Max(childItems.Count, MIN_ITEM_SPACE) / (2.0f * Mathf.PI);
                //  add one unused position to item positions
                childPositions = ArrangeInCircle(childItems.Count + 1, radius);
            }
            for (int i = 0; i < childItems.Count; ++i)
            {
                Vector3 posOffset = childPositions[i];
                ConstellationMenuIcon childMenu = (ConstellationMenuIcon)Instantiate(root.menuIconPrefab, root.transform);
                childMenu.transform.position   = parent.menuCenter + (orientation * posOffset);
                childMenu.transform.rotation   = orientation;
                childMenu.transform.localScale = Vector3.one * scale;
                childMenu.Initialize(root, parent, childItems[i], parent.menuCenter, scale, initialState);
                childMenu.angleToRoot = Mathf.Atan2(posOffset[1], posOffset[0]);
            }

            return(true);
        }