コード例 #1
0
ファイル: ScrewDriver.cs プロジェクト: onghuisheng/LastTrain
    public override void OnGrab()
    {
        base.OnGrab();

        m_ScrewDriver.transform.position = Controller.transform.position;
        m_ScrewDriver.transform.rotation = Quaternion.LookRotation(-Controller.transform.forward);
        ScrewDriverClone = Instantiate(m_ScrewDriver, transform.position, transform.rotation, m_ScrewDriver.transform);
        base.OnGrabStay();
        m_ScrewDriver.GetComponent <MeshRenderer>().enabled = false;
        Destroy(ScrewDriverClone.GetComponent("ScrewDriver"));
        ScrewDriverClone.GetComponent <Rigidbody>().useGravity = false;
        bIsGrabbing   = true;
        RotationValue = ScrewDriverClone.transform.rotation.eulerAngles.z;

        foreach (Screw screw in m_Screws)
        {
            Negi.Outline outline = screw.GetComponent <Negi.Outline>();

            if (outline == null && Vector3.Distance(transform.position, screw.transform.position) < 2)
            {
                screw.gameObject.AddComponent <Negi.Outline>();
            }
            else
            {
                outline.enabled = true;
            }
        }
    }
コード例 #2
0
ファイル: ScrewDriver.cs プロジェクト: onghuisheng/LastTrain
    public override void OnGrabReleased()
    {
        base.OnGrabReleased();

        m_ScrewDriver.GetComponent <MeshRenderer>().enabled = true;
        Destroy(ScrewDriverClone);
        bIsGrabbing = false;

        foreach (Screw screw in m_Screws)
        {
            Negi.Outline outline = screw.GetComponent <Negi.Outline>();

            if (outline != null)
            {
                outline.enabled = false;
            }
        }
    }