public override void GetItems(bool refresh, bool rebuildGlobalLists, bool resetTextures) { bool newBounds = true; active = visible; if (resetTextures) { DisposeTextures(); } maskNodeGroup = GetGroup <TC_NodeGroup>(0, refresh, resetTextures); if (maskNodeGroup == null) { active = false; } else { maskNodeGroup.type = NodeGroupType.Mask; if (maskNodeGroup.active) { if (newBounds) { bounds = maskNodeGroup.bounds; } else { bounds.Encapsulate(maskNodeGroup.bounds); } } } if (t.childCount <= 1) { active = false; } else { Transform child = t.GetChild(1); groupResult = child.GetComponent <TC_LayerGroupResult>(); if (groupResult == null) { TC.MoveToDustbin(child); active = false; } else { groupResult.SetParameters(this, 1); groupResult.GetItems(refresh, rebuildGlobalLists, resetTextures); if (!groupResult.active) { active = false; } } } }
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; } } }
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(); } } }
public void LinkClone(TC_LayerGroupResult resultLayerGroupS) { preview = resultLayerGroupS.preview; for (int i = 0; i < itemList.Count; i++) { TC_Layer layer = itemList[i] as TC_Layer; if (layer != null) { TC_Layer layerS = resultLayerGroupS.itemList[i] as TC_Layer; layer.LinkClone(layerS); } else { TC_LayerGroup layerGroup = itemList[i] as TC_LayerGroup; if (layerGroup != null) { TC_LayerGroup layerGroupS = resultLayerGroupS.itemList[i] as TC_LayerGroup; layerGroup.LinkClone(layerGroupS); } } } }
static public void Draw(TC_LayerGroup layerGroup, ref Vector2 pos, float posOldX, float activeMulti, bool nodeFoldout) { TC_GlobalSettings g = TC_Settings.instance.global; TC_LayerGroupResult groupResult = layerGroup.groupResult; float x1 = pos.x - 78; if (groupResult.foldout < 2) { x1 += nodeFoldout ? 126 : 135; } x1 -= TD.texCardBody.width / 2; float y1 = pos.y + (layerGroup.nodeFoldout ? TD.cardHeight : 32); TD.DrawTextureScaled(x1 - (TD.texShelfLinesConnectUp.width / 2), y1 - 16, TD.texShelfLinesConnectUp, Color.white); TD.DrawTextureScaled(x1 - (TD.texShelfLinesConnectUp.width / 2), y1 - 16, TD.texLineConnectUp, g.colLayer * activeMulti); x1 += 30; if (layerGroup.foldout == 2 && groupResult.itemList.Count > 0) { TD.DrawTextureScaled(x1, y1 + 16, posOldX - x1 - g.layerHSpace, TD.texShelfLinesHorizontal, Color.white); TD.DrawTextureScaled(x1, y1 + 16, posOldX - x1 - g.layerHSpace, TD.texLineHorizontal, g.colLayer * activeMulti); } else { Vector2 posOld = pos; pos.x = x1 + 52; pos.y += layerGroup.nodeFoldout ? 258 : -94; int mouseClick = TD.DrawNodeCount(groupResult, ref pos, groupResult.itemList.Count, true, ref layerGroup.foldout, g.colLayer * activeMulti, g.rect.width); if (groupResult.itemList.Count == 0) { if (mouseClick == 0) { groupResult.Add <TC_Layer>("", false); } else if (mouseClick == 1) { groupResult.Add <TC_LayerGroup>("", false); } } else { if (mouseClick == 0) { layerGroup.nodeFoldout = true; } } pos = posOld; } TD.DrawBracket(ref pos, nodeFoldout, true, g.colLayerGroup * activeMulti, ref groupResult.foldout, true, true); if (groupResult.foldout == 2) { bool isCulled = false; pos.x -= TD.texCardBody.width; TD.DrawNode(groupResult, pos, g.colLayer, Color.white, ref isCulled, activeMulti, nodeFoldout, false, true); int mouseButton = TD.Button(new Rect(pos.x + 245.1f, pos.y + 6.5f, 20, 20), TD.texFoldout, true, new Color(1, 1, 1, 0.25f), Color.white, Color.white, true); if (mouseButton == 0) { if (layerGroup.foldout == 0) { layerGroup.foldout = 2; } else { layerGroup.foldout = 0; } } } else { if (nodeFoldout) { TD.DrawNodeCount(groupResult, ref pos, 1, true, ref groupResult.foldout, g.colLayerGroup * activeMulti, 1); } } TD.DrawBracket(ref pos, nodeFoldout, false, g.colLayerGroup * activeMulti, ref groupResult.foldout, true, true); }