Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Splitting up a texture and UV-mapping different parts to a plane?

Discussion in 'Scripting' started by fribergo, Sep 1, 2015.

  1. fribergo

    fribergo

    Joined:
    Apr 1, 2014
    Posts:
    23
    Hey guys!

    My UV-knowledge isn't the best, but I'm reading up on it. But let's say that I have a procedural plane (supposed to be a house-wall) made from a script (with random length and height between 3 and 10 units), and then a texture that's divided into 4 parts e.g.:

    Upper left part is simple wall texture,
    Upper right part is a big window,
    Lower left part is a smaller window, and
    Lower right part is a door.

    Now my question is: is it possible to combine the different parts of the chopped up texture and assign to the plane (two triangles)? For example, if the wall is 3x3 units and then have a texture applied to it that's something like:

    [wall] [wall] [wall]
    [big.wind] [small.wind] [big.wind]
    [wall] [door] [wall]

    Right now I have chopped up the texture within the script, but don't know how to assign more than one texture to a single plane. Is this way possible? Or should I go in another direction?
     
  2. DuffyT

    DuffyT

    Joined:
    Dec 16, 2014
    Posts:
    37
    I suggest you watch quill18's tutorials on youtube, he has a whole series that goes over this.



    To answer your question, I don't think you can. You need vertices to assign uv's to and if you only have four vertices you can only have four uv-coordinates meaning one texture. You could try building (and re-building) a single texture in code but I think that's going to be complicated. I used a different method in my project. I build a plane in code with many quads (four vertices per quad) and apply a texture from an atlas directly. Coding-wise this is alot easier IMO, I just look up the correct uv-coordinates using a simple bit of code. It's the same way described in the tutorial.
     
    fribergo likes this.
  3. fribergo

    fribergo

    Joined:
    Apr 1, 2014
    Posts:
    23
    Okay, I see... Then I guess I got my night in front of the TV cut out for me :) Have watched some of his stuff, but must have missed this part. Thanks for the tip!