public NodeWindow(Node node) { this.windowIndex = indexCount; indexCount++; // cast to specific type if(node is GeneratorNode) { generatorNode = (GeneratorNode)node; type = WINDOWTYPE.GENERATOR; node.title = generatorNode.type.ToString(); } if(node is OperatorNode){ operatorNode = (OperatorNode)node; type = WINDOWTYPE.OPERATOR; node.title = operatorNode.type.ToString(); } if(node is OutputNode) { outputNode = (OutputNode)node; type = WINDOWTYPE.OUTPUT; previewSize = PreviewSize.x2; } if(node is MacroNode) { macroNode = (MacroNode)node; type = WINDOWTYPE.MACRO; } if(node is TextureNode) { textureNode = (TextureNode)node; type = WINDOWTYPE.TEXTURE; } if(node is ColorNode) { colorNode = (ColorNode)node; gradient = new GradientWrapper(); gradient.GradientData = colorNode.gradient; type = WINDOWTYPE.COLOR; } // also save general reference this.node = node; // random connection color connectionColor = new Color(Random.Range(100, 200) / 255f, Random.Range(100, 200) / 255f, Random.Range(100, 200) / 255f); UpdatePreview(); node.rect.height = controlHeight + (int)previewSize; node.rect.width = (int)previewSize + 20; if(node.rect.width < 200) node.rect.width = 200; if(showOutputOptions) showOutputOptions = false; }
private bool FindOutputNode() { // find outputnode and texture nodes output = null; textureNodes = new List <TextureNode>(); for (int i = 0; i < nodes.Count; i++) { Node n = nodes[i]; if (n is OutputNode) { output = (OutputNode)n; } if (n is TextureNode) { textureNodes.Add((TextureNode)n); } } if (output == null) { Debug.LogError("OutputNode not found"); return(false); } return(true); }
private void New() { // create starting nodes settings = new TerrainModule(); savepath = ""; GeneratorNode g1 = new GeneratorNode(100, 100); g1.seed = Random.Range(-100000, 100000); OutputNode output = new OutputNode(700, 100); output.Connect(g1, 0); settings.nodes.Add(g1); settings.nodes.Add(output); // create windows to represent nodes windows.Clear(); windows.Add(new NodeWindow(g1)); windows.Add(new NodeWindow(output)); }
private bool FindOutputNode() { // find outputnode and texture nodes output = null; textureNodes = new List<TextureNode>(); for(int i = 0; i < nodes.Count; i++) { Node n = nodes[i]; if(n is OutputNode) { output = (OutputNode)n; } if(n is TextureNode) { textureNodes.Add((TextureNode)n); } } if(output == null) { Debug.LogError("OutputNode not found"); return false; } return true; }
public NodeWindow(Node node) { this.windowIndex = indexCount; indexCount++; // cast to specific type if (node is GeneratorNode) { generatorNode = (GeneratorNode)node; type = WINDOWTYPE.GENERATOR; node.title = generatorNode.type.ToString(); } if (node is OperatorNode) { operatorNode = (OperatorNode)node; type = WINDOWTYPE.OPERATOR; node.title = operatorNode.type.ToString(); } if (node is OutputNode) { outputNode = (OutputNode)node; type = WINDOWTYPE.OUTPUT; previewSize = PreviewSize.x2; } if (node is MacroNode) { macroNode = (MacroNode)node; type = WINDOWTYPE.MACRO; } if (node is TextureNode) { textureNode = (TextureNode)node; type = WINDOWTYPE.TEXTURE; } if (node is ColorNode) { colorNode = (ColorNode)node; if (colorNode.gradient == null) { colorNode.gradient = new Gradient(); if (colorNode.gradientColorKeys != null) { colorNode.gradient.colorKeys = SerializableGradientColorKey.ToGradientColorKeys(colorNode.gradientColorKeys); colorNode.gradient.alphaKeys = SerializableGradientAlphaKey.ToGradientColorKeys(colorNode.gradientAlphaKeys); } gradient = new GradientWrapper(); gradient.GradientData = colorNode.gradient; } type = WINDOWTYPE.COLOR; } // also save general reference this.node = node; // random connection color connectionColor = new Color(Random.Range(100, 200) / 255f, Random.Range(100, 200) / 255f, Random.Range(100, 200) / 255f); UpdatePreview(); node.rect.height = controlHeight + (int)previewSize; node.rect.width = (int)previewSize + 20; if (node.rect.width < 200) { node.rect.width = 200; } }