Search Unity

AssetDatabase.CreateAsset() for textures

Discussion in 'Asset Database' started by XGT08, Sep 21, 2017.

  1. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,909
    Hi there,

    I am using the AssetDatabase.CreateAsset() to create texture assets inside the editor. So what I am doing is I have a bunch of textures, apply a trimming algorithm to them, and then save the result in separate texture assets. It works really well and the textures are created, but when I click on the texture asset, I can not see all the properties that you usually get for textures (texture type, grayscale, mipmapping, filter etc). I only get wrap mode, filter and aniso level properties.

    Is there a way to have the generated texture asset show the same properties as the other textures?

    Thanks,
    Andrew
     
  2. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,909
    So here's a screenshot of what I am expecting:
    ExpectedInspector.png

    But this is what I get:
    WhatIGet.png
     
  3. XGT08

    XGT08

    Joined:
    Aug 1, 2013
    Posts:
    1,909
    Ok. Figured it out. The textures needs to first be saved as an image file with a valid image extension :)
     
    futurlab_xbox likes this.
  4. Fangh

    Fangh

    Joined:
    Apr 19, 2013
    Posts:
    278
    If you save the image, why would you want to create an asset from the image ? You will have twice the file if you do that, don't you ?
     
  5. komodor

    komodor

    Joined:
    Jan 2, 2013
    Posts:
    36
    well it's clear he won't use CreateAsset anymore but instead will ImportAsset the file :D (as he didn't mention it in the second post)