<commit_before>﻿namespace VRTK
{
    using UnityEngine;

    public abstract class VRTK_SDKControllerReady : MonoBehaviour
    {
        protected VRTK_SDKManager sdkManager;
        protected SDK_BaseController previousControllerSDK;

        protected virtual void OnEnable()
        {
            sdkManager = VRTK_SDKManager.instance;
            if (sdkManager != null)
            {
                sdkManager.LoadedSetupChanged += LoadedSetupChanged;
            }
            CheckControllersReady();
        }

        protected virtual void OnDisable()
        {
            if (sdkManager != null)
            {
                sdkManager.LoadedSetupChanged -= LoadedSetupChanged;
                UnregisterPreviousLeftController();
                UnregisterPreviousRightController();
            }
        }

        protected virtual void LoadedSetupChanged(VRTK_SDKManager sender, VRTK_SDKManager.LoadedSetupChangeEventArgs e)
        {
            RegisterLeftControllerReady();
            RegisterRightControllerReady();
            CheckControllersReady();
            previousControllerSDK = VRTK_SDK_Bridge.GetControllerSDK();
        }

        protected virtual void CheckControllersReady()
        {
            VRTK_ControllerReference leftRef = VRTK_DeviceFinder.GetControllerReferenceLeftHand();
            VRTK_ControllerReference rightRef = VRTK_DeviceFinder.GetControllerReferenceRightHand();

            if (VRTK_ControllerReference.IsValid(leftRef))
            {
                RegisterLeftControllerReady();
                ControllerReady(leftRef);
            }

            if (VRTK_ControllerReference.IsValid(rightRef))
            {
                RegisterRightControllerReady();
                ControllerReady(rightRef);
            }
        }

        protected virtual void UnregisterPreviousLeftController()<commit_msg>fix(Internal): ensure controller ready registration is always done<commit_after>﻿namespace VRTK
{
    using UnityEngine;

    public abstract class VRTK_SDKControllerReady : MonoBehaviour
    {
        protected VRTK_SDKManager sdkManager;
        protected SDK_BaseController previousControllerSDK;

        protected virtual void OnEnable()
        {
            sdkManager = VRTK_SDKManager.instance;
            if (sdkManager != null)
            {
                sdkManager.LoadedSetupChanged += LoadedSetupChanged;
            }
            CheckControllersReady();
        }

        protected virtual void OnDisable()
        {
            if (sdkManager != null)
            {
                sdkManager.LoadedSetupChanged -= LoadedSetupChanged;
                UnregisterPreviousLeftController();
                UnregisterPreviousRightController();
            }
        }

        protected virtual void LoadedSetupChanged(VRTK_SDKManager sender, VRTK_SDKManager.LoadedSetupChangeEventArgs e)
        {
            CheckControllersReady();
            previousControllerSDK = VRTK_SDK_Bridge.GetControllerSDK();
        }

        protected virtual void CheckControllersReady()
        {
            RegisterLeftControllerReady();
            RegisterRightControllerReady();

            VRTK_ControllerReference leftRef = VRTK_DeviceFinder.GetControllerReferenceLeftHand();
            VRTK_ControllerReference rightRef = VRTK_DeviceFinder.GetControllerReferenceRightHand();

            if (VRTK_ControllerReference.IsValid(leftRef))
            {
                ControllerReady(leftRef);
            }

            if (VRTK_ControllerReference.IsValid(rightRef))
            {
                ControllerReady(rightRef);
            }
        }

        protected virtual void UnregisterPreviousLeftController()
{'fraction_non_alphanumeric': 0.05977819853935624, 'fraction_numerical': 0.0, 'mean_word_length': 2.063794531897266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5935054', 'n_tokens_mistral': 884, 'n_tokens_neox': 834, 'n_words': 148}