Ejemplo n.º 1
0
        void OnEnable()
        {
            //Initialize in OnEnable instead of Awake to support fast enter play mode.
            //When not reloading the scene, [ExecuteAlways] scripts won't have Awake called.
            if (Application.IsPlaying(this) && !_definition)
            {
                enabled = false;
                throw new UnassignedReferenceException("No RagdollDefinition was assigned.");
            }

            if (!IsInitialized)
            {
                IsInitialized = TryCreateRagdollBones();
                if (IsInitialized)
                {
                    OnBonesCreated?.Invoke();
                }
            }
            else
            {
                foreach (RagdollBone bone in Bones)
                {
                    bone.ResetJointAxisOnEnable();
                }
            }
        }
Ejemplo n.º 2
0
        void OnValidate()
        {
            if (Application.isPlaying)
            {
                return;
            }

            if (!IsInitialized || !BindingsMatchExistingBones)
            {
                IsInitialized = TryCreateRagdollBones();
                if (IsInitialized)
                {
                    OnBonesCreated?.Invoke();
                }
            }
        }