Announcement

Collapse
No announcement yet.

Is this correct? about temporary UTexture2D

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Is this correct? about temporary UTexture2D

    Hi guys,

    In editor plugin module, I create many temporary UTexture2D object, when I save them to disk, did I need to delete them?

    is this code correct?

    Code:
    UTexture2D* tmpTex = UTexture2D::CreateTransient(size, size);
    // fill tex
    DSUtility::FillTex2D(tmpTex, FColor::Black);
    FString path = CosmosGenCfg::DefaultAssetPath;
    assetName = TEXT("Neblua_");
    //	save to new content asset
    DSEditorUtility::CreateTexture2DAsset(tmpTex, path, assetName);
    
    // no need this tmpText, how can I destroy it?
    // is this correct?
    if (tmpTex && tmpTex->IsValidLowLevel())
    	tmpTex = nullptr;
    Last edited by ckcfcc; 04-02-2016, 10:47 AM.

    #2
    anybody can give me some note?

    Comment


      #3
      UClass's such as UTexture2D are automatically garbage collected when there is no hard pointer references made to that object. So if you just leave it and don't reference it elsewhere then it will be destroyed automatically.

      IF you still need to manually remove it I believe you can call ConditionalBeginDestroy() or something like that, but it is probably better to just leave it.

      Comment


        #4
        thank you Dec1234

        Comment

        Working...
        X