- Home /
#pragma strict and NotificatonCenterGenerics
Hi guys,
I have some code that plays nicely with http://www.unifycommunity.com/wiki/index.php?title=NotificationCenterGenerics as long as my code isn't set to #pragma strict. Here is the code:
function AddScore(notification: Notification) { score += notification.data; }
function AddGems(notification: Notification) { gems += notification.data; }
If I use #pragma strict, I get this error:
Assets/Game Logic/LevelStatus.js(119,15): BCE0051: Operator '+' cannot be used with a left hand side of type 'int' and a right hand side of type 'Object'.
This is because data is an untyped variable in class Notification in the wiki code link. In order to get around the strict compilation issue, the code that I wrote needs some way to determine data's datatype. What should I do?
MachCUBED
Answer by whydoidoit · May 27, 2012 at 12:36 AM
Try this:
var i : int = notification.data;
score += i;
Your answer
![](https://koobas.hobune.stream/wayback/20220613072004im_/https://answers.unity.com/themes/thub/images/avi.jpg)