예제 #1
0
        protected override void OnEnable()
        {
            Simulation.Instance.StepCallbacks.PreStepForward += OnPreStepForwardCallback;
            Simulation.Instance.StepCallbacks.SimulationPre  += OnSimulationPre;
            if (MainCamera != null)
            {
                m_camera = MainCamera.GetComponent <Camera>();
            }

            m_lineShape    = new agxCollide.Line(new agx.Vec3(), new agx.Vec3(0, 0, 1));
            m_lineGeometry = new agxCollide.Geometry(m_lineShape);
            m_lineGeometry.setEnable(false);
            m_lineGeometry.setSensor(true);
            GetSimulation().add(m_lineGeometry);
        }
예제 #2
0
        protected override void OnDisable()
        {
            if (Simulation.HasInstance)
            {
                Simulation.Instance.StepCallbacks.PreStepForward -= OnPreStepForwardCallback;
                Simulation.Instance.StepCallbacks.SimulationPre  -= OnSimulationPre;

                GetSimulation().remove(m_lineGeometry);
            }

            if (ConstraintGameObject != null)
            {
                Destroy(ConstraintGameObject);
            }

            ConstraintGameObject = null;
            m_distanceFromCamera = -1f;
            m_camera             = null;
            m_lineShape          = null;
            m_lineGeometry       = null;
        }