Page 1 of 1

[ImportedComponent] May Be Bugged

Posted: Thu Sep 30, 2021 6:57 pm
by l3lessed
So, I'm at a stand still with the [ImportedComponent] object. It is working wonderfully at applying my script object to any prefabbed objects used in varied animals for the most part. However, when this component is called for importing and attaching a script to a prefab model with multiple sub-models and skinned mesh renderers, it only will apply the script to the first animal object (in my instance horses) and then not apply it to any of the subsequent models.

I removed all added code to the script and reverted it back to the simple scaling script, and it still does it. So, I know it isn't any of my coding additions. And when I look at the [ImportedComponent] code itself, it seems to be looping through allot of things, and I'm wondering the prefab having multiple sub-models could be causing it to get stuck or fail.

Any ideas or assistance would be greatly appreciated. Am I as usual just not understanding how this works? I'm just thrown off because it doesn't affect prefabbed animals with only one sub-model and mesh renderer, and I get no error or log messages referencing anything about this.

Here is the script code:

Code: Select all

namespace DaggerfallWorkshop.Game.RandomVariations
{
    [ImportedComponent]
    public class HorseController : MonoBehaviour
    {
        [SerializeField]
        private float min = 1f;

        [SerializeField]
        private float max = 1.25f;        

        private void Awake()
        {
            float scale = UnityEngine.Random.Range(min, max);
            transform.localScale = Vector3.Scale(transform.localScale, new Vector3(scale, scale, scale));
        }

    }
}
I created a debug log at one point to see exactly what was being replaced with the horses and here are the outputs. This was when I was applying textures to the object. I removed this to ensure it wasn't my code screwing things up, and the same thing happened:
Image

Here is the first horse showing the attached script
Image

Here is the second horse showing no attached script.
Image

Re: [ImportedComponent] May Be Bugged

Posted: Thu Sep 30, 2021 10:01 pm
by l3lessed
One other small side note. If the script is forced onto the object post scene creation through either the editor or using a script loop with .addcomponent<HorseController>() in it, it all runs as it should.

Re: [ImportedComponent] May Be Bugged

Posted: Fri Oct 01, 2021 5:02 pm
by TheLacus
Hi, can you upload minimum assets/prefabs to replicate the issue? It's fine to have multiple components even on children, so i don't know why it doesn't work here.

Re: [ImportedComponent] May Be Bugged

Posted: Fri Oct 01, 2021 7:47 pm
by l3lessed
Will do. I'll throw it up the two horse prefabs causing it with the master script and the controller script attached to the prefab.

Let me see if I can get it up sometime today. As of now, I have found a hackey work around scanning the location flats for any that have been replaced and then force it onto the object with an add component.

Re: [ImportedComponent] May Be Bugged

Posted: Fri Oct 15, 2021 6:03 pm
by l3lessed
Running into this issue again with other components attached to the prefab. It won't import anything I'm adding to the prefab for one of the 201_0 horse texture replacement, but works fine for the 201_1 horse texture replacement.

I updated my github. You can replicate this issue by grabbing the mods asset folder and dumping it into your editor build. Load it up and check the console for the errors about not finding the attached components. Click on a 201_0 horse replacement, and see none of the prefab added components attached, like the character controller and mesh collider. Click on a 201_1 horse texture replacement, and all prefab attached components are there and working as should.

https://github.com/l3lessed/l3lessed-DF ... l3DAnimals

Re: [ImportedComponent] May Be Bugged

Posted: Thu Nov 04, 2021 11:19 pm
by TheLacus
This is what i did:

1. Create a script with the content from your first post.
2. Attach it to prefab 201_0 (from your repo).
3. Build mod.
4. Load save.

The component was restored to all prefab instances in the scene. I think i need more specific instructions to replicate the issue described on the first post.