[ImportedComponent] May Be Bugged
Posted: Thu Sep 30, 2021 6:57 pm
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:
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:
Here is the first horse showing the attached script
Here is the second horse showing no attached script.
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));
}
}
}
Here is the first horse showing the attached script
Here is the second horse showing no attached script.