Search Unity

Discussion Missing script references that actually works on instantiated prefabs

Discussion in 'Asset Bundles' started by RafaelGomes00, Jul 21, 2022.

  1. RafaelGomes00

    RafaelGomes00

    Joined:
    Aug 13, 2020
    Posts:
    73
    [Edit] I changed the script inside the project folder (without any changes on the asset bundle) and it compiled, it seems to be something with the Unity UI, but if so shouldn't my references like texture, mesh and color still exist?

    [Edit] I managed to discover why my references where missing, it was because i unloaded the asset bundle before it instantiates the GameObjects. But i still get missing script references.

    Hello, I just discovered something really strange happening on my project, and I'm trying to get some insights on this:

    Basically the problem is: I download an prefab inside an scriptable object from a server,

    Code (CSharp):
    1. public void InitiateObject()
    2.     {
    3.         if (currentActiveGo.activeInHierarchy)
    4.         {
    5.             currentActiveGo.SetActive(false);
    6.             bundleDownloader.GetBundleObject("object", InstantiateGO);
    7.         }
    8.         else
    9.         {
    10.             currentActiveGo.SetActive(true);
    11.             Destroy(cGO);
    12.         }
    13.     }
    then, i instantiate that prefab that has some scripts on it (Important).

    Code (CSharp):
    1. private void InstantiateGO(CCSet cSet)
    2.     {
    3.         Debug.Log(cSet.cGo);
    4.         cGO = Instantiate(cSet.cGo, new Vector3(0, 0, 0), new Quaternion(0, -180, 0, 0));
    5.         cGO.GetComponent<CCPlacer>().Initialize();
    6.  
    And calls some functions that this scripts have,

    Code (CSharp):
    1. [SerializeField] private List<CCMeshHolder> meshes;
    2.  
    3.     public void Initialize()
    4.     {
    5.         foreach(CCMeshHolder mesh in meshes)
    6.         {
    7.             mesh.Initialize();
    8.         }
    9.     }
    Code (CSharp):
    1. public void Initialize()
    2.     {
    3.         Debug.Log("Initializing " + this.gameObject.name);
    4.         List<Material> newMaterials = new List<Material>();
    5.  
    6.         foreach (MaterialStruct mat in materials)
    7.         {
    8.             Material nMat = new Material(mat.materialShader);
    9.  
    10.             nMat.SetTexture("_DiffuseMap", mat.diffuseMap);
    11.             nMat.SetTexture("_NormalMap", mat.normalMap);
    12.             nMat.SetTexture("_AOMap", mat.ao);
    13.             nMat.SetTexture("_FacMap", mat.facMap);
    14.  
    15.             nMat.SetColor("_PrimaryColor", mat.initialPrimaryColor);
    16.             nMat.SetColor("_SecondaryColor", mat.initialSecondaryColor);
    17.  
    18.             nMat.SetFloat("_Alpha", mat.alpha);
    19.  
    20.             newMaterials.Add(nMat);
    21.         }
    22.         meshRenderer.sharedMaterials = newMaterials.ToArray();
    23.     }

    BUT, i noticed that the scripts on the editor are missing references for themselves.

    So, A Missing script is attached to a GameObject, but is actually compilable.

    upload_2022-7-21_13-39-35.png
    upload_2022-7-21_11-48-35.png
     
    Last edited: Jul 22, 2022