Exemple #1
0
        public static EventParam GetEventParam(int EventContextInd, int varInd)
        {
            UnityEventData eventData = GetEventData(EventContextInd);

            if (eventData.eventParams != null &&
                eventData.eventParams.Length > varInd)
            {
                return(eventData.eventParams[varInd]);
            }
            return(null);
        }
Exemple #2
0
        // return last value of data param of *persistent* event
        public static EventParam GetLastEventParam(string eventName, string paramName)
        {
            UnityEventData eventData = GetLastEventData(eventName);

            if (eventData != null)
            {
                return(GetEventParam(eventData, paramName));
            }

            return(null);
        }
Exemple #3
0
        public static void TriggerDataEvent(UnityEventData unityEventData)
        {
            if (unityEventData == null || unityEventData.eventName == "")
            {
                VRsqrUtil.Debug.Log(LogLevel.Error, "TriggerDataEvent: Illegal unityEventData argument");
                return;
            }

            UnityEventInt thisEvent      = null;
            bool          listenerExists = instance.NameToListenedEventDictionary.TryGetValue(unityEventData.eventName, out thisEvent);

            VRsqrUtil.Debug.LogInfo("TriggerDataEvent: eventName = " + unityEventData.eventName + "    listenerExists = " + listenerExists);
            if (unityEventData.presistentData || listenerExists) // there is at least one listerner to this event
            {
                int eventContextInd = GetFreeEventDataInd();
                int dataBufferInd   = eventContextInd % numDataBuffers;
                eventDataBuffers[dataBufferInd] = unityEventData;
                eventDataBuffers[dataBufferInd].eventContextInd = eventContextInd;

                // keep the index of the most recent triggering of this event - to support getting values of past events (e.g. in case of persistent events with no listener)
                //instance.NameToLastEventIndDictionary.Add(unityEventData.eventName.ToLower(), dataBufferInd);
                instance.NameToLastEventIndDictionary[unityEventData.eventName] = dataBufferInd;

                unityEventData.varInd = new Dictionary <string, int>();
                if (unityEventData.eventParams != null)
                {
                    for (int i = 0; i < unityEventData.eventParams.Length; i++)
                    {
                        //unityEventData.varInd.Add(unityEventData.eventParams[i].NameString.ToLower(), i);
                        //unityEventData.varInd[unityEventData.eventParams[i].NameString.ToLower()] = i;
                        unityEventData.eventParams[i].NameString = VRsqr_EventsManager.StandardizeString(unityEventData.eventParams[i].NameString);
                        unityEventData.varInd[unityEventData.eventParams[i].NameString] = i;
                        VRsqrUtil.Debug.Log(LogLevel.Debug, "---------- TriggerDataEvent: NameString = " + unityEventData.eventParams[i].NameString +
                                            " , ValString = " + unityEventData.eventParams[i].ValString +
                                            " , paramObjVal = " + unityEventData.eventParams[i].paramObjVal);
                    }
                }

                if (listenerExists)
                {
                    thisEvent.Invoke(eventContextInd);
                }
            }
        }
Exemple #4
0
        public static EventParam GetEventParam(UnityEventData eventData, string varName)
        {
            varName = StandardizeString(varName);

            int varInd = 0;

            if (varName != null && eventData != null &&
                eventData.varInd != null &&
                eventData.varInd.TryGetValue(varName, out varInd))
            {
                VRsqrUtil.Debug.LogInfo("GetEventParam: varName = " + varName + " return eventData.eventParams[varInd] = " + eventData.eventParams[varInd]);
                return(eventData.eventParams[varInd]);
            }
            else
            {
                VRsqrUtil.Debug.Log(LogLevel.Warning, "GetEventParam: Illegal arguments - eventData = " + eventData + " , varName = " + varName + " , eventData.varInd = " + eventData.varInd);
            }
            return(null);
        }
Exemple #5
0
        void eventHandler_In(int EventContextInd)
        {
            UnityEventData eventData = VRsqr_EventsManager.GetEventData(EventContextInd);

            VRsqr_EventsManager.TriggerDataEvent(eventData);
        }
Exemple #6
0
        public static double getEventOutTime(int EventContextInd)
        {
            UnityEventData eventData = GetEventData(EventContextInd);

            return(eventData.eventOutTimeStamp);
        }
Exemple #7
0
        public static EventParam GetEventParam(int EventContextInd, string varName)
        {
            UnityEventData eventData = GetEventData(EventContextInd);

            return(GetEventParam(eventData, varName));
        }
Exemple #8
0
        public static EventParam[] GetEventDataVars(int EventContextInd)
        {
            UnityEventData eventData = GetEventData(EventContextInd);

            return(eventData.eventParams);
        }
Exemple #9
0
        public static int GetEventDataVarsNum(int EventContextInd)
        {
            UnityEventData eventData = GetEventData(EventContextInd);

            return(eventData.eventParams.Length);
        }