Пример #1
0
        static public void DeleteKey()
        {
            if (Selection.transforms != null)
            {
                for (int i = 0; i < Selection.transforms.Length; i++)
                {
                    Transform t = Selection.transforms[i];

                    TC_LayerGroup       layerGroup      = t.GetComponent <TC_LayerGroup>();
                    TC_LayerGroupResult groupResult     = t.GetComponent <TC_LayerGroupResult>();
                    TC_SelectItemGroup  selectItemGroup = t.GetComponent <TC_SelectItemGroup>();
                    TC_NodeGroup        nodeGroup       = t.GetComponent <TC_NodeGroup>();
                    TC_Node             node            = t.GetComponent <TC_Node>();

                    if (node != null)
                    {
                        if (node.nodeType == NodeGroupType.Select)
                        {
                            TC_NodeGroup nodeGroupParent = (TC_NodeGroup)node.parentItem;
                            if (nodeGroupParent.itemList.Count == 1 && node.outputId != TC.heightOutput)
                            {
                                TC.AddMessage("Select node cannot be deleted as there is always minimum one needed in a Layer."); continue;
                            }
                        }
                    }
                    else if (layerGroup != null)
                    {
                        if (layerGroup.level == 0)
                        {
                            TC.AddMessage("The main " + TC.outputNames[layerGroup.outputId] + " Output Layer Group cannot be deleted. \n\nRight click to clear it."); continue;
                        }
                    }
                    else if (groupResult != null)
                    {
                        TC.AddMessage("A Result Node cannot be deleted. The Layer Group itself needs to be deleted."); continue;
                    }
                    else if (selectItemGroup != null)
                    {
                        selectItemGroup.Clear(true); continue;
                    }
                    else if (nodeGroup != null)
                    {
                        nodeGroup.Clear(true); continue;
                    }

                    Undo.DestroyObjectImmediate(Selection.gameObjects[i]);
                    --i;
                }
            }
        }
Пример #2
0
        static public void DuplicateKey()
        {
            Transform[] transforms = (Transform[])Selection.transforms.Clone();

            if (transforms != null)
            {
                List <GameObject> gos = new List <GameObject>();

                for (int i = 0; i < transforms.Length; i++)
                {
                    Transform t = transforms[i];

                    TC_LayerGroup       layerGroup      = t.GetComponent <TC_LayerGroup>();
                    TC_LayerGroupResult groupResult     = t.GetComponent <TC_LayerGroupResult>();
                    TC_SelectItemGroup  selectItemGroup = t.GetComponent <TC_SelectItemGroup>();
                    TC_NodeGroup        nodeGroup       = t.GetComponent <TC_NodeGroup>();

                    if (layerGroup != null)
                    {
                        if (layerGroup.level == 0)
                        {
                            TC.AddMessage("The main " + TC.outputNames[layerGroup.outputId] + " Output Layer Group cannot be duplicated."); continue;
                        }
                    }
                    else if (groupResult != null)
                    {
                        TC.AddMessage("A Result Node cannot be duplicated."); continue;
                    }
                    else if (selectItemGroup != null)
                    {
                        TC.AddMessage("A " + TC.outputNames[selectItemGroup.outputId] + " Group cannot be directly duplicated.\n\nDrag & drop works with it, while dropping hold the alt key to duplicate it."); continue;
                    }
                    else if (nodeGroup != null)
                    {
                        TC.AddMessage("A " + nodeGroup.type.ToString() + " Group cannot be directly duplicated.\n\nDrag & drop works with it, while dropping hold the alt key to duplicate it."); continue;
                    }

                    TC_ItemBehaviour item = t.GetComponent <TC_ItemBehaviour>();
                    if (item != null)
                    {
                        gos.Add(item.Duplicate(item.transform.parent).gameObject);
                    }
                }
                if (gos.Count > 0)
                {
                    Selection.objects = gos.ToArray();
                }
            }
        }
Пример #3
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;
            }
        }
Пример #4
0
        static public int Draw(TC_SelectItemGroup selectItemGroup, ref Vector2 pos, Color color, Color colSelectItem, Color colBracket, float activeMulti)
        {
            bool nodeFoldout = selectItemGroup.parentItem.nodeFoldout;

            // bool select = false;
            // Draw total node
            // DropDownMenu();
            //if (selectItemGroup.itemList.Count > 1)
            //{
            // RenderTexture previewTex;
            // if (selectItemGroup.itemList.Count == 1) previewTex = selectItemGroup.itemList[0].displayRenderTex; else previewTex = selectItemGroup.displayRenderTex;
            // startOffset.x -= TD.texCardBody.width;

            TD.DrawBracket(ref pos, nodeFoldout, true, colBracket * activeMulti, ref selectItemGroup.foldout, true, selectItemGroup.itemList.Count > 0);

            //if (TC_Settings.instance.hasMasterTerrain && selectItemGroup.outputId != TC.treeOutput && selectItemGroup.outputId != TC.objectOutput)
            //{
            //    Vector2 sliderPos = TD.GetPosition(new Vector2(startOffset.x + 6, (startOffset.y + 84)));
            //    GUIUtility.ScaleAroundPivot(new Vector2(TD.scale / 1.5f, TD.scale / 1.5f), new Vector2(sliderPos.x, sliderPos.y));

            //    if (selectItemGroup.itemValues.values.Count > 0)
            //    {
            //        GUI.changed = false;

            //        selectItemGroup.itemValues.values[0].mix = GUI.HorizontalSlider(new Rect(sliderPos.x, sliderPos.y, 93, 10), selectItemGroup.itemValues.values[0].mix, 0, 1.5f);
            //        if (GUI.changed) selectItemGroup.CalcSelectItemGroupPreview();
            //    }
            //// selectItemGroup.itemValues.values[index].value = GUIW.MinMaxSlider(new Rect(sliderPos.x, sliderPos.y + 20, 78, 10), selectItemGroup.itemValues.values[index].value, 0.0f, 100.0f, new Vector2(200.0f, 25.0f));

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

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

            if (selectItemGroup.foldout > 0)
            {
                if (selectItemGroup.itemList.Count > 1)
                {
                    bool isCulled = false;
                    pos.x -= TD.texCardBody.width;
                    TD.DrawNode(selectItemGroup, pos, color, Color.white, ref isCulled, activeMulti, nodeFoldout, false, false);
                }

                if (selectItemGroup.foldout == 2)
                {
                    TC_SelectItem selectItem;
                    for (int i = selectItemGroup.itemList.Count - 1; i >= 0; --i)
                    {
                        selectItem = selectItemGroup.itemList[i];
                        //if (index < 0)
                        //{
                        //    startOffset.x -= 5;
                        //    if (TC.filterGroups[-(index + 1)].Draw(ref startOffset, color, colorFilter, -(index + 1)) == 1) LeftClickMenu("Erase FilterGroup");
                        //}
                        if (selectItem != null)
                        {
                            pos.x -= TD.nodeWidthHSpace;
                            TC_SelectItemGUI.Draw(selectItemGroup, activeMulti, i, nodeFoldout, ref pos, colSelectItem);
                        }
                    }
                }
            }

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

            TD.DrawBracket(ref pos, nodeFoldout, false, colBracket * activeMulti, ref selectItemGroup.foldout, true, selectItemGroup.itemList.Count > 0);

            return(0);
        }
Пример #5
0
        public override void GetItems(bool refresh, bool rebuildGlobalLists, bool resetTextures)
        {
            if (resetTextures)
            {
                DisposeTextures();
            }

            active = visible;
            // Init();
            // InitPreview(ref rtPreview);
            bool newBounds = true;

            maskNodeGroup = GetGroup <TC_NodeGroup>(0, refresh, resetTextures);
            if (maskNodeGroup != null)
            {
                maskNodeGroup.type = NodeGroupType.Mask;
                if (maskNodeGroup.totalActive > 0)
                {
                    bounds    = maskNodeGroup.bounds;
                    newBounds = false;
                }
            }

            selectNodeGroup = GetGroup <TC_NodeGroup>(1, refresh, resetTextures);
            if (selectNodeGroup != null)
            {
                selectNodeGroup.type = NodeGroupType.Select;
                if (selectNodeGroup.totalActive == 0)
                {
                    TC_Reporter.Log("SelectNodeGroup 0 active"); active = false;
                }
                else
                {
                    if (newBounds)
                    {
                        bounds = selectNodeGroup.bounds;
                    }
                    else
                    {
                        bounds.Encapsulate(selectNodeGroup.bounds);
                    }
                }
            }
            else
            {
                active = false;
            }

            if (outputId != TC.heightOutput)
            {
                selectItemGroup = GetGroup <TC_SelectItemGroup>(2, refresh, resetTextures);
                if (selectItemGroup != null)
                {
                    if (selectItemGroup.totalActive == 0)
                    {
                        TC_Reporter.Log("itemGroup 0 active"); active = false;
                    }
                    else if (selectItemGroup.itemList.Count <= 1)
                    {
                        // TODO: Make better solution for this
                        selectNodeGroup.useConstant = true;
                        if (selectNodeGroup.itemList.Count > 0)
                        {
                            selectNodeGroup.itemList[0].visible = true;
                            active = visible;
                            GetGroup <TC_NodeGroup>(1, true, resetTextures);
                        }
                    }
                    else
                    {
                        selectNodeGroup.useConstant = false;
                    }
                }
                else
                {
                    active = false;
                }
            }
        }