/// <summary> /// Create layer with given shapes and gameColors, is automatically an input layer /// precondition: shapes and colors must be equal in length /// </summary> /// <param name="shapes"></param> textures of black shapes to add to nodes /// <param name="colors"></param> colors for each node /// <param name="xPosition"></param> x position of layer /// <param name="startingY"></param> y postition of top node public Layer(Texture2D[] shapes, GameColor[] colors, float xPosition, float startingY, int Layernumber) { nodes = new Node[shapes.Length]; for (int i = 0; i < nodes.Length; i++) { Texture2D modifiedShape = ShapeModifer.changeColor(shapes[i], colors[i]); nodes[i] = new Node(modifiedShape); } x = xPosition; isInputLayer = true; isOutPutLayer = false; setUpPostions(startingY); number = Layernumber; }
public void setUpNode() { if (startingTexture != null) { if (startingColor != null) { Texture2D modifiedTex = ShapeModifer.changeColor(startingTexture, new GameColor(startingColor)); node = new Node(modifiedTex); } else { node = new Node(startingTexture); } } else { node = new Node(); } setUpNodeType(); }
// Start is called before the first frame update void Start() { //GameTexture firstLayer = ShapeModifer.changeColor(new GameTexture(startingTexture), new GameColor(startingColor)); Texture2D firstLayer = ShapeModifer.changeColor(startingTexture, new GameColor(startingColor)); //Debug.Log(firstLayer); Node thisNode = new Node(firstLayer); //thisNode.addTex(new GameTexture(addLayers[0])); for (int i = 0; i < addLayers.Length; i++) { Texture2D thisTex = addLayers[i]; GameColor thisColor = new GameColor(addColors[i]); GameTexture newTex = new GameTexture(ShapeModifer.changeColor(thisTex, thisColor)); Node newNode = new Node(newTex); thisNode.addNode(newNode); } for (int i = 0; i < subLayers.Length; i++) { GameTexture thisTex = new GameTexture(subLayers[i]); GameColor thisColor = new GameColor(subColors[i]); GameTexture newTex = ShapeModifer.changeColor(thisTex, thisColor); Node newNode = new Node(newTex); thisNode.subNode(newNode); } Texture2D tex = thisNode.GetTexture2D(); //Texture2D tex = firstLayer.getTex(); Sprite newSprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f); rend.sprite = newSprite; }