예제 #1
0
        static public void Draw(TC_SelectItemGroup selectItemGroup, float activeMulti, int index, bool nodeFoldout, ref Vector2 pos, Color color)
        {
            TC_SelectItem selectItem = selectItemGroup.itemList[index];

            Undo.RecordObject(selectItem, selectItem.name);

            Rect rectPreview;
            bool isCulled = false;

            if (selectItem.outputId == TC.colorOutput)
            {
                if (selectItem.texColor != null && selectItem.parentItem.itemList.Count == 1)
                {
                    rectPreview = TD.DrawNode(selectItem, pos, color, Color.white, ref isCulled, activeMulti, nodeFoldout, false, false);
                }
                else
                {
                    rectPreview = TD.DrawNode(selectItem, pos, color, selectItem.color, ref isCulled, activeMulti, nodeFoldout, false, false);
                }
            }
            else
            {
                rectPreview = TD.DrawNode(selectItem, pos, color, Color.white, ref isCulled, activeMulti, nodeFoldout, false, !selectItem.splatCustom);
            }
            if (isCulled || !nodeFoldout)
            {
                return;
            }

            if (TC_Settings.instance.hasMasterTerrain)
            {
                Vector2 sliderPos = TD.GetPositionScaled(new Vector2(pos.x + 10.5f, pos.y + 297.5f));
                GUIUtility.ScaleAroundPivot(new Vector2(TD.scale * 2.25f, TD.scale * 2.25f), new Vector2(sliderPos.x, sliderPos.y));

                if (selectItem.outputId != TC.objectOutput)
                {
                    if (selectItem.outputId == TC.colorOutput)
                    {
                        Color colOld = selectItem.color;
                        if (Event.current.button != 2)
                        {
                            selectItem.color = EditorGUI.ColorField(new Rect(sliderPos.x, sliderPos.y + 4, 93, 10), selectItem.color);
                        }
                        else
                        {
                            EditorGUI.ColorField(new Rect(sliderPos.x, sliderPos.y + 4, 93, 10), selectItem.color);
                        }
                        selectItem.color.a = 1;
                        if (selectItem.color != colOld)
                        {
                            selectItem.Refresh();
                        }
                    }
                    else
                    {
                        int selectIndexOld = selectItem.selectIndex;
                        int total          = selectItem.GetItemTotalFromTerrain();
                        if (total > 1)
                        {
                            if (selectItem.outputId == TC.treeOutput)
                            {
                                sliderPos.y -= 17;
                            }
                            if (Event.current.button != 2)
                            {
                                selectItem.selectIndex = (int)GUI.HorizontalSlider(new Rect(sliderPos.x, sliderPos.y, 110, 16), selectItem.selectIndex, 0, total - 1);
                            }
                            else
                            {
                                GUI.HorizontalSlider(new Rect(sliderPos.x, sliderPos.y, 110, 16), selectItem.selectIndex, 0, total - 1);
                            }
                        }

                        if (selectItem.selectIndex != selectIndexOld)
                        {
                            selectItem.Refresh();
                        }
                    }
                }

                if (selectItem.outputId == TC.splatOutput)
                {
                    // if (selectItem.splatCustom) DrawSplatCustomPreview(selectItem, rectPreview);
                }

                GUI.matrix = Matrix4x4.Scale(new Vector3(1, 1, 1));

                TC_NodeGUI.DrawAddItem(rectPreview, pos, selectItem);
                TC_NodeGUI.LeftClickMenu(rectPreview, selectItem);
            }

            if (selectItem.outputId != TC.colorOutput)
            {
                Rect colorRect = new Rect(rectPreview.x + 0 * TD.scale, rectPreview.y + 0 * TD.scale, 60 * TD.scale, 16f * TD.scale);
                GUI.color = new Color(selectItem.color.r, selectItem.color.g, selectItem.color.b, 0.75f);
                GUI.DrawTexture(colorRect, Texture2D.whiteTexture);
                GUI.color = Color.white;
            }
        }
        static public int Draw(TC_NodeGroup nodeGroup, ref Vector2 pos, Color colGroupNode, Color colNode, Color colBracket, float activeMulti, bool nodeFoldout, bool drawMethod, bool colorPreviewTex, bool hideSelectNodes)
        {
            if (nodeGroup == null)
            {
                return(0);
            }
            // bool select = false;
            // Draw total node

            Rect  dropDownRect;
            float activeMultiOld = activeMulti;

            activeMulti *= nodeGroup.active ? 1 : 0.75f;

            bool isCulled       = false;
            TC_GlobalSettings g = TC_Settings.instance.global;

            // if ((nodeGroup.foldout == 1 && nodeGroup.itemList.Count == 1) || nodeGroup.itemList.Count == 0) nodeGroup.foldout = 0;

            // Closing Bracket
            TD.DrawBracket(ref pos, nodeFoldout, true, colBracket * activeMultiOld, ref nodeGroup.foldout, true, nodeGroup.itemList.Count > 0);

            if (nodeGroup.foldout > 0)
            {
                if ((nodeGroup.itemList.Count != 1 || nodeGroup.foldout != 1) && nodeGroup.itemList.Count != 0 && !hideSelectNodes)
                {
                    pos.x -= TD.texCardBody.width;
                }

                if (nodeGroup.itemList.Count > 1 && !hideSelectNodes)
                {
                    dropDownRect = TD.DrawNode(nodeGroup, pos, colGroupNode, Color.white, ref isCulled, activeMulti, nodeFoldout, drawMethod, false);
                    if (nodeGroup.foldout == 2)
                    {
                        pos.x -= TD.texCardBody.width + g.nodeHSpace;
                    }
                    DropDownMenu(dropDownRect, nodeGroup);
                }

                //if (colorPreviewTex)
                //{
                //    startOffset.x -= TD.nodeWidth;
                //    TD.DrawNode(nodeGroup, drawMethod, ref startOffset, true, color, click, Color.white, ref isCulled);
                //    startOffset.x -= TD.nodeWidth;
                //}

                // Draw ()
                //if (nodeGroup.itemList.Count > 1)
                //{
                //    startOffset.x += 10;

                //    Draw ItemList Count
                //    if (!nodeGroup.foldout)
                //    {
                //        TD.DrawRect(new Rect(startOffset.x - 9, (startOffset.y + TD.nodeHeight / 2) - 5, 18, 10), TC_Settings.instance.global.colTextBackGround);
                //        TD.DrawText(new Vector2(startOffset.x + 2, startOffset.y + TD.nodeHeight / 2), nodeGroup.itemList.Count.ToString(), 8, FontStyle.Bold, Color.white, HorTextAlign.Center, VerTextAlign.Center);
                //    }
                //    startOffset.x -= TD.nodeWidthSpace;
                //}

                if (nodeGroup.foldout == 2 && !hideSelectNodes)
                {
                    if (nodeGroup.itemList.Count > 1 && nodeFoldout)
                    {
                        TD.DrawMethod(nodeGroup, pos + new Vector2(TD.texCardBody.width - 18, 172), true, colNode, activeMulti);
                    }

                    for (int i = nodeGroup.itemList.Count - 1; i >= 0; --i)
                    {
                        TC_Node node = nodeGroup.itemList[i] as TC_Node;

                        if (node != null)
                        {
                            TC_NodeGUI.Draw(node, nodeFoldout, i == 0 ? false : true, pos, colNode, activeMulti);
                            if (i != 0)
                            {
                                pos.x -= TD.nodeWidthHSpace;
                            }
                            if (node.inputKind != InputKind.Current && node.inputKind != InputKind.Portal && i != 0 && nodeFoldout)
                            {
                                TD.DrawMethod(node, pos + new Vector2(TD.texCardBody.width - 18, 172), false, colNode, (node.active ? 1 : 0.5f) * activeMulti);
                            }
                        }
                        else
                        {
                            TC_NodeGroup nodeGroupChild = nodeGroup.itemList[i] as TC_NodeGroup;

                            if (nodeGroupChild != null)
                            {
                                pos.x += TD.nodeWidthHSpace;
                                Draw(nodeGroupChild, ref pos, colGroupNode, colNode, colBracket, activeMulti, nodeFoldout, drawMethod, false, false);
                                if (i != 0)
                                {
                                    pos.x -= TD.nodeWidthHSpace;
                                    TD.DrawMethod(nodeGroupChild, pos + new Vector2(TD.texCardBody.width - 18, 172), false, colNode, (nodeGroupChild.active ? 1 : 0.5f) * activeMulti);
                                }
                            }
                        }
                    }
                }
            }

            if (nodeFoldout)
            {
                int mouseClick = TD.DrawNodeCount(nodeGroup, ref pos, nodeGroup.itemList.Count, nodeFoldout, ref nodeGroup.foldout, (nodeGroup.foldout == 1 && nodeGroup.itemList.Count != 1 ? colGroupNode * 0.75f : colBracket) * activeMulti);
                if (mouseClick == 0 && nodeGroup.itemList.Count == 0)
                {
                    nodeGroup.Add <TC_Node>("", false, false, true);
                }
            }

            // Opening Bracket
            TD.DrawBracket(ref pos, nodeFoldout, false, colBracket * activeMultiOld, ref nodeGroup.foldout, true, nodeGroup.itemList.Count > 0);

            return(0);
        }