Code: Select all
go.AddComponent<ClimateCalories>();
instance = go.AddComponent<ClimateCalories>();
Code: Select all
instance = go.AddComponent<ClimateCalories>();
Code: Select all
go.AddComponent<ClimateCalories>();
instance = go.AddComponent<ClimateCalories>();
Code: Select all
instance = go.AddComponent<ClimateCalories>();
Code: Select all
using UnityEngine;
using DaggerfallWorkshop.Game;
using DaggerfallWorkshop.Game.Utility.ModSupport;
using DaggerfallWorkshop;
namespace MyMod
{
public class MyMod : MonoBehaviour
{
static Mod mod;
[Invoke(StateManager.StateTypes.Start, 0)]
public static void Init(InitParams initParams)
{
mod = initParams.Mod;
var go = new GameObject(mod.Title);
go.AddComponent<MyMod>();
DaggerfallUnity.LogMessage("MyMod Init()", true);
PlayerActivate.RegisterCustomActivation(mod, 210, 16, TorchSound);
PlayerActivate.RegisterCustomActivation(mod, 210, 17, TorchSound);
PlayerActivate.RegisterCustomActivation(mod, 210, 18, TorchSound);
}
private void Awake()
{
// Do required stuff on Awake
DaggerfallUnity.LogMessage("MyMod Awake()", true);
}
private static void TorchSound(RaycastHit hit)
{
DaggerfallUI.Instance.PlayOneShot(SoundClips.ActivateGears);
}
}
}
When caching your own references, you should always check reference != null when accessing later. Remember - you can't guarantee execution order in your mod so caching these references early won't always work out for you.If I use [Invoke(StateManager.StateTypes.Start, 0)] and I use a nested reference, or what you'd call it, something seriously breaks. At least if it happens in OnNewMagicRound. See post above for more details.
This could be impacted by above, best just use StateTypes.Start from here on out. Also if object names change or aren't what is registered, then custom activations won't work. That seems to be case in the third one below.If I use [Invoke(StateManager.StateTypes.Game, 0)] items and sprite activation in the loaded environment breaks. The items lose their className. I do not what happens to make the RegisterCustomActivation break.
Game objects cloned from prefabs always get (clone) on the end in my experience. I'm honestly not sure how or why this seems to have changed between builds. I also note the difference you describe, but it's not something we've (intentionally) changed from build to build. Sometimes Unity just gonna Unity. BadLuckBurt had a pretty good workaround on page 2.GameObjects are named with "Clone" at the end.
Code: Select all
If(gameObject.name.StartsWith("DaggerfallLight [Dungeon]"))