Search Unity

How do I add a material to an object?

Discussion in 'Editor & General Support' started by BlobVanDam, Jul 24, 2010.

  1. BlobVanDam

    BlobVanDam

    Joined:
    Jun 28, 2010
    Posts:
    88
    Yes, this may sound like a stupid question, but I cannot find a way to fix the material on the base object in the library. I know how to change it for an instance in the scene, or for a prefab, but how the hell do I fix it on the actual object itself? I don't want it saying missing material, and I don't want to have to remake my entire material every time I re-import my object. I have a material for it, it just won't let me drag it on there. It shouldn't be so damn difficult. I somehow managed to do it yesterday, but I can't figure out how I did it.
     
  2. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    In the Project panel click the Create drop down at the top and choose Material,
    highlight your object and drag the material onto the object properties in the Inspector.
    If you exported your object with materials applied they should have come in to Unity with the model.
     
  3. BlobVanDam

    BlobVanDam

    Joined:
    Jun 28, 2010
    Posts:
    88
    I can't drag the material onto it, because when it's just in the project it's completely greyed out and does nothing. Drag and drop only works when it's in the scene, in which case it's only fixing it for that instance in the scene, and not the object I imported. And when I import a model, it just remakes it's blank material with an extra folder, which I don't want. I just want to assign my pre-made material that is already set up correctly.
     
  4. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    I'm sure I don't know what is going on, are you exporting as FBX and have materials applied in your 3D program
    and those materials are not importing into Unity?
     
  5. BlobVanDam

    BlobVanDam

    Joined:
    Jun 28, 2010
    Posts:
    88
    When I import my fbx, it automatically generates a new folder with a new default blank useless material. But it already had a completely finished material I'd already made. I am simply reimporting the model because I slightly changed it (but want to keep the same material I already spent my time on). The problem is that it ignores the material it already has and still insists on generating a new one again with an automatically generated filename I don't want.
    My only way of fixing up the material for the new object in the project is to rebuild my entire material from scratch on the new automatically generated one. This is just wasting my time time when I've already gone to the trouble of making the material. It should allow drag and drop for project objects.
     
  6. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    I just ran a test and created a cube in Max,
    exported it without adding a material and clicked on it in the Project panel and it has a Main Color Base material on it,
    which I can drag a material to and it applies to the object.
    (Unity 3.0.0b4)
     
  7. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Try deleting the fbx file in the project (in windows it will go to the recycle bin) and then export the model again using the original fbx name.
    Here it retains all the original textures.
    When exporting are you exporting to the project folder where the original fbx file is, using the same name?
    If so, it should just overwrite the previous version of the file, retaining the textures.
     
  8. BlobVanDam

    BlobVanDam

    Joined:
    Jun 28, 2010
    Posts:
    88
    I export directly overwriting the existing model. It doesn't retain my materials. It always creates a new sub-folder with an automatically named material rather than keeping what was already assigned.
    If you can find a way that dragging a new material to an object is supposed to work in 2.6, let me know.
     
  9. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Dunno, just tried it in 2.6.1f3 and it is the same.
     
  10. BlobVanDam

    BlobVanDam

    Joined:
    Jun 28, 2010
    Posts:
    88
    That's the exact version I have. You're dragging a material to an object in the project panel? Maybe I'm doing something stupid, because it doesn't work for me. How are you doing it? I've tried selecting the object in the project panel, and dragging the material to it, but it doesn't work like that. For me to change the material on an object, I have to put it in the scene, in which case it's not doing what I want, it's just changing the material for that instance of the model, not the model itself.
     
  11. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    The model already has a material on it form Max, without me assigning one.
    If I drag a material on an instance in the Hierarchy Panel (scene) it also changes on the object in the Project panel.
    How large is your model and the textures and can you share it? You could send it and I could try it here.
     
  12. BlobVanDam

    BlobVanDam

    Joined:
    Jun 28, 2010
    Posts:
    88
    It has a material on it from Max for me too, but it's just not keeping the changed material in Unity when I re-import it. It will create a new material every time. If I delete it's new material, the model now says missing material, and there's no way to fix it. And if I delete my old material and use the new one, then I have to go through the hassle of rebuilding my material, and it screws up my prefabs.
    And when I drag a material onto the object in the hierarchy panel, it doesn't change the object in the project panel for me. I've wasted an entire day trying to drag a material onto a damn object.
     
  13. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Well, I can certainly empathize with your frustration.
    Guess I'm not sure how you really got into this position,
    I always just assign unique material names (IDs) in Max and then just add texture maps in Unity.
    I don't think I've ever deleted the material folder that came in with the export,
    just dragged my texture maps into the default material slots.
    Wish I could help but I'm not even going to try to diagnose the details of your problem without seeing the model myself.
    Can you rename the material folder you want to keep,
    re-import the model, and replace the materials already on the model with the ones you created in Unity?
    I'm sure the answer is "no", but I really don't know why.
    How about if you rename the materials to the names they have in Max and overwrite the ones in the FBX folder?

    Hope you find a solution.
     
  14. blblopez

    blblopez

    Joined:
    Oct 12, 2014
    Posts:
    1
    I recently experienced a similar situation. Try this:

    1. Create Material however you normally would.
    2. Click and drag the material to the object in the hierarchy panel (NOT the inspector, as you would expect).

    Now when you click on that object, in the inspector you should have that material you click-dragged and it should no longer be greyed out. Hope that helps! Good luck!
     
    StarskiTM and obanerj like this.
  15. DavidEzra1

    DavidEzra1

    Joined:
    Sep 1, 2015
    Posts:
    1
    What i did was highlighted my material, did Ctrl+C, clicked my object, and did Ctrl+V. Hope this helps.
     
  16. silvac

    silvac

    Joined:
    Feb 4, 2018
    Posts:
    1
    I also had this problem and fixed it by minimizing components of the object until there was some gray space in the inspector. Only then would the drag and drop work for my materials.
     
  17. StarskiTM

    StarskiTM

    Joined:
    May 14, 2022
    Posts:
    1
    You are a life saver
     
  18. baloonblitz6000

    baloonblitz6000

    Joined:
    Nov 13, 2023
    Posts:
    1
    i dont know if this will help but if anyone is having this issue, try to find just the materials and none of the other assets in the hierarchy and then change the shaders to whatever you need