Ejemplo n.º 1
0
        // Start is called before the first frame update

        protected void Awake()
        {
            if (oneTime)
            {
                messages      = new SortedList();
                scriptEnabled = true;
                packageIndex  = 0;
                if (gameObjectSpecificPrefix)
                {
                    Vector3 position = gameObject.transform.position;
                    Vector3 rotation = gameObject.transform.rotation.eulerAngles;
                    Vector3 scale    = gameObject.transform.lossyScale;

                    Vector3 index = position + scale + rotation;

                    prefix = prefix + gameObject.name + (gameObject.transform.childCount + index.magnitude).ToString();
                }

                if (!UDPConnectionManager.CheckIfPrefixExist(prefix))
                {
                    UDPConnectionManager.AddPrefix(prefix);
                }
                UDPConnectionManager.AddToMessageHandler(prefix, this);
                oneTime = false;
            }
        }
Ejemplo n.º 2
0
 public void RestoreToState()
 {
     if (state != null && state.StateIsSaved())
     {
         List <object> variables = state.GetVariables();
         SortedList    coping    = (SortedList)variables[0];
         SortedList    copy      = new SortedList(coping);
         messages      = copy;
         scriptEnabled = (bool)variables[1];
         prefix        = (string)variables[2];
         packageIndex  = (int)variables[3];
         if (!UDPConnectionManager.CheckIfPrefixExist(prefix))
         {
             UDPConnectionManager.AddPrefix(prefix);
         }
         UDPConnectionManager.AddToMessageHandler(prefix, this);
     }
 }
Ejemplo n.º 3
0
        void OnEnable()
        {
            scriptEnabled = true;

            if (oneTime)
            {
                if (gameObjectSpecificPrefix)
                {
                    Vector3 position = gameObject.transform.position;
                    Vector3 rotation = gameObject.transform.rotation.eulerAngles;
                    Vector3 scale    = gameObject.transform.lossyScale;

                    Vector3 index = position + scale + rotation;

                    prefix = prefix + gameObject.name + (gameObject.transform.childCount + index.magnitude).ToString();
                }
                UDPConnectionManager.AddPrefix(prefix);
                scriptEnabled = true;
                Debug.Log("Handler added");
                oneTime = false;
            }
        }