Пример #1
0
    void Start()
    {
        //locate the cyPIPESParsePost component on the master cyPIPES prefan in the scene
        cyPIPESnetwork = GameObject.Find("cyPIPES").GetComponent <cyPIPESparsePost> ();

        //Dig to find all virtual cyPIPES unit GameObjects
        try{
            foreach (GameObject unit in cyPIPESnetwork.allUnitObjects.Values)
            {
                cyPIPESunits.Add(unit);
                controlList.Add(unit.GetComponent <cyPIPES>());
                controlUnit.Add(unit.name, unit.GetComponent <cyPIPES>());
            }
        }catch {
            if (cyPIPESErrorsActive)
            {
                Debug.LogError("cyPIPES ERROR: Cannot find virtual cyPIPES Unit(s) for manual control.");
            }
        }
    }
    //Awake function use just in case developers dynamically instatiate effects after runtime.
    void Awake()
    {
        //Reference cyPIPES Layer Mask
        cyPIPESlayer = LayerMask.NameToLayer("cyPIPES");

        //Reference cyPIPES master object
        try{
            cyPIPESmgmtObj = GameObject.Find("cyPIPES");
        }catch {
            if (cyPIPESErrorsActive)
            {
                Debug.LogError("cyPIPES ERROR: FX Projection having a hard time finding the cyPIPES master object. Have you added it to the scene? It should be located in Assets/cyPIPES/Prefabs");
            }
        }
        //Reference the VR play space object from cyPIPES<cyPIPESParsePost.cs>.  This also acts as a double check that users might not have made another object called cyPIPES
        try{
            if (cyPIPESmgmtObj != null)
            {
                vrPlaySpace = cyPIPESmgmtObj.GetComponent <cyPIPESparsePost>().vrPlaySpaceObj;
            }
        }catch {
            //Looks like cyPIPESPasePost is not present. This is likely because a seconed object is named "cyPIPES" and is not the cyPIPES master object
            if (cyPIPESErrorsActive)
            {
                Debug.LogError("cyPIPES ERROR: Effects objects cannot reference the vr play space from cyPIPES master object. Do you have another object in the scene named \"cyPIPES\"? If so please rename or remove it so that only the cyPIPES master prefab has this name.");
            }

            //Checking for custom vr play space and custom user object
            if (vrPlaySpace == null)
            {
                if (userObj == null)
                {
                    if (cyPIPESLogActive)
                    {
                        Debug.Log("cyPIPES Log: A custom VR tracked space has been detected. If you are using a custom user object other than the one in [CameraRig] please manually link it as userObj in each fx object");
                    }
                }
            }
        }
        //Refrencing cyPIPEStileNormalization component
        try{
            recordSource = cyPIPESmgmtObj.GetComponent <cyPIPEStileNormalization>();
        }catch {
            if (cyPIPESErrorsActive)
            {
                Debug.LogError("cyPIPES ERROR: Unable to reference cyPIPEStileNormalization.cs from cyPIPES master object be sure it is active");
            }
        }
        //Referenceing parser component
        try{
            parser = cyPIPESmgmtObj.GetComponent <cyPIPESparsePost>();
        }catch {
            if (cyPIPESErrorsActive)
            {
                Debug.LogError("cyPIPES ERROR: Unable to reference cyPIPESparsePost.cs from cyPIPES master object be sure it is active");
            }
        }
        //Reference user object
        try{
            //if userObj is not manually assigned as a custom one, reference the Camera (eye) in [CameraRig]
            if (userObj == null)
            {
                userObj = vrPlaySpace.transform.GetChild(2);
            }
        }catch {
            if (cyPIPESErrorsActive)
            {
                Debug.LogError("cyPIPES ERROR: " + this.gameObject.name + " unable to reference user object from [CameraRig] component.");
            }
        }

        //Reference userMonitor
        try{
            userInfo = cyPIPESmgmtObj.GetComponent <cyPIPESuserMonitor>();
        }catch {
            if (cyPIPESErrorsActive)
            {
                Debug.LogError("cyPIPES ERROR: vEFD refrencing issue with cyPIPESuserMonitor.");
            }
        }

        //Make a copy of tile record with a public function so that developers could call later for updates to tile record.
        updateTileRecord();
    }