protected void Awake()
        {
            item   = this.GetComponent <Item>();
            module = item.data.GetModule <ItemModuleBinoculars>();
            body   = this.GetComponent <Rigidbody>();

            // setup item events
            item.OnGrabEvent       += OnGrabEvent;
            item.OnUngrabEvent     += OnUngrabEvent;
            item.OnHeldActionEvent += OnHeldAction;

            SetupScopeLeft(item.definition.GetCustomReference(module.leftScopeID), item.definition.GetCustomReference(module.leftScopeCameraID).GetComponent <Camera>());
            SetupScopeRight(item.definition.GetCustomReference(module.rightScopeID), item.definition.GetCustomReference(module.rightScopeCameraID).GetComponent <Camera>());
            if (!string.IsNullOrEmpty(module.zoomSoundsID))
            {
                zoomSounds = item.definition.GetCustomReference(module.zoomSoundsID).GetComponents <AudioSource>();
            }
        }
Example #2
0
        protected void Awake()
        {
            item   = this.GetComponent <Item>();
            module = item.data.GetModule <ItemModuleBinoculars>();
            body   = this.GetComponent <Rigidbody>();

            // setup item events
            item.OnGrabEvent       += OnGrabEvent;
            item.OnUngrabEvent     += OnUngrabEvent;
            item.OnHeldActionEvent += OnHeldAction;

            SetupScope(item.GetCustomReference(module.leftScopeID), item.GetCustomReference(module.leftScopeCameraID).GetComponent <Camera>(), ref scopeL, ref scopeCameraL, ref originalScopeMaterialL, ref scopeMaterialL, ref renderScopeTextureL);
            SetupScope(item.GetCustomReference(module.rightScopeID), item.GetCustomReference(module.rightScopeCameraID).GetComponent <Camera>(), ref scopeR, ref scopeCameraR, ref originalScopeMaterialR, ref scopeMaterialR, ref renderScopeTextureR);
            if (!string.IsNullOrEmpty(module.zoomSoundsID))
            {
                zoomSounds = item.GetCustomReference(module.zoomSoundsID).GetComponents <AudioSource>();
            }
        }