#There is the ISerialization interface

1 messages · Page 1 of 1 (latest)

slender bone
#

i have no clue why it's happening.

#

I think because of the nature of Texture2dArray, unity decides to save it

#

It also happens with meshes for example

#

(which i have the same issue and need to find a way to delete it) but because they are UnityObjects they get always serialized and stored into the scene

cyan field
#

That is patent nonsense. Nothing gets saved unless YOU tell it to. So if things are being saved it's because you have made it so

slender bone
#

Wait, I want to be clear that im creating those assets in Editor Mode

slender bone
# cyan field That is patent nonsense. Nothing gets saved unless YOU tell it to. So if things ...

If you still think that tho, just tried making a new project, added this script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteAlways]
public class Test : MonoBehaviour
{
    private Mesh mesh;
    private Texture2DArray rry;
    // Start is called before the first frame update
    void OnEnable()
    {
        mesh = new Mesh();
        mesh.name = "New Mesh";
        rry = new Texture2DArray(10,10,1,TextureFormat.Alpha8, true);
        rry.name = "New Text Test";
        Debug.Log("mesh created");

        var filter = GetComponent<MeshFilter>();
        filter.sharedMesh = mesh;
    }
}

and saving the scene and i got a "New Mesh" saved into the scene object. Not sure if shared mesh counts as making it so that it is saved?

cyan field
#

what do you think [ExecuteAlways] does?

slender bone
#

It's so it gets always executed, both in editor and play mode, no?

cyan field
#

exactly, so if you do a New anything Unity object it get created in your scene

slender bone
cyan field
#

so if you dont want them to persist use DestroyImediate in OnDestroy

#

or am I missing some context here?

slender bone
#

Not that I think no, im gonna check if OnDestroy gets called tho before a save. Im not sure it does

#

yeah no, OnDestroy doesn't get called

#

I cannot find any event or method that I can use before scene saving for me to delete the unnecessary data

#

Okay found the scenesaving event