Skip to content

Virtual Override Methods not working correctly? #109

@Deaadman

Description

@Deaadman

I was developing a mod for The Long Dark, trying to create a derived class from within the game. The code snippet goes like this:

public class Panel_ModMenu : Panel_AutoReferenced 
{
    private BasicMenu m_BasicMenu;
    public GameObject m_BasicMenuRoot;

    public Panel_ModMenu(IntPtr ptr) : base(ptr) { }

    public override void Initialize()
    {
        base.Initialize();
        m_BasicMenu = BasicMenu.InstantiateMenu(InterfaceManager.s_BasicMenuPrefab, m_BasicMenuRoot, gameObject, this);
    }

    public override void Enable(bool enable)
    {
        base.Enable(enable);
        if (enable)
        {
            m_BasicMenu.Enable(true);
            GameManager.GetCameraEffects().DepthOfFieldTurnOn();
            return;
        }
        m_BasicMenu.Enable(false);
        GameManager.GetCameraEffects().DepthOfFieldTurnOff(false);
    }
}

The issue I'm facing is with the override void methods. The Panel_Base class which the Panel_AutoReferenced class also inherits isn't abstract. The Initialized override method could be getting called from the virtual void method within the Panel_Base class to initialize this new panel. But it isn't, and whenever I try to call my Initialize method manually - a recursion occurs.

Unless I've missed something, or it's not working because I don't know how to code - this might be an error with this project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgenerationRelated to assembly generation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions