private void Start()
    {
        renterTextrue      = new RenderTexture((int)resolution.x, (int)resolution.y, 16, RenderTextureFormat.ARGB32);
        renterTextrue.name = "rt_" + senderName;

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        spoutReceiver = gameObject.AddComponent <SpoutReceiver>();
#elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
        syphonReceiver = gameObject.AddComponent <SyphonClient>();
#endif
        if (spoutReceiver != null)
        {
            spoutReceiver.targetTexture = renterTextrue;
        }
        if (syphonReceiver != null)
        {
            syphonReceiver.targetTexture = renterTextrue;
        }

        rawImage         = GetComponent <RawImage>();
        rawImage.texture = renterTextrue;

        //combox生成
        CreateComboBox();
    }
Example #2
0
        public void init(stereo side, string baseName, string instanceName, GameObject go)
        {
            this.side = side;
            string textureSuffix = (side == stereo.Left) ? ("Left") : ("Right");

            this.spoutName = baseName + instanceName + textureSuffix;

            this.spout       = go.AddComponent <SpoutReceiver>() as SpoutReceiver;
            spout.sourceName = this.spoutName;

            setTexture(1, 1);
        }
Example #3
0
    public void init(stereo side, string cameraBaseName, string interopBaseName)
    {
        this.side = side;
        string cameraSuffix = (side == stereo.Left) ? ("Left") : ("Right");
        string cameraName   = cameraBaseName + cameraSuffix;

        var cameras = GameObject.FindObjectsOfType <Camera>();

        foreach (var c in cameras)
        {
            if (c.name == cameraName)
            {
                this.camera = c; // TODO: not safe
            }
        }
        if (this.camera == null)
        {
            Debug.LogError("EyeResources init(): could not find camera named '" + cameraName + "'");
            return;
        }
        this.meshHolder = new GameObject(cameraName + "Mesh");

        this.sourceName = interopBaseName + cameraName;
        this.meshHolder.AddComponent <SpoutReceiver>(); // need to attach SpoutReceiver Script to some object, can not simply make 'new'
        this.spout          = this.meshHolder.GetComponent <SpoutReceiver>();
        spout.sourceName    = this.sourceName;
        spout.targetTexture = this.texture;

        // set up colored quad with spout texture in front of camera
        this.material      = new Material(Shader.Find("Unlit/Transparent"));
        this.material.name = cameraName + "Material";
        this.setTexture(cameraName + "Texture", 1, 1);

        // we have to use a GameObject to make the quad follow the cameras position
        this.meshHolder.AddComponent <MeshFilter>();
        this.meshHolder.AddComponent <MeshRenderer>();
        this.quadMesh = this.meshHolder.GetComponent <MeshFilter>().mesh;
        this.meshHolder.transform.SetParent(this.camera.transform, false);
        this.meshRenderer           = this.meshHolder.GetComponent <MeshRenderer>();
        this.meshRenderer.materials = new Material[] { this.material };

        var eye = (side == stereo.Left) ? (Camera.MonoOrStereoscopicEye.Left) : (Camera.MonoOrStereoscopicEye.Right);
        // if camera is in mono mode (e.g. for testing), the frustum corners calculated for Left/Right eye frustum are broken
        if (camera.stereoActiveEye == Camera.MonoOrStereoscopicEye.Mono)
        {
            eye = Camera.MonoOrStereoscopicEye.Mono;
        }

        setQuadToCameraCorners(this.quadMesh, this.camera, eye);
    }
 public void SetSpout(string source)
 {
     if (selectedSource != source)
     {
         selectedSource = source;
         foreach (Transform child in objSpoutReceivedContainer.transform)
         {
             Destroy(child.gameObject);
         }
         //create new receiver
         var projectGameObject = Instantiate(prefabSpoutReceiver, objSpoutReceivedContainer.transform);
         _receiver            = projectGameObject.GetComponent <SpoutReceiver>();
         _receiver.nameFilter = selectedSource;
         foreach (var item in spoutItems)
         {
             item.ChangeBackground(item.name == selectedSource ? imgBackgroundSelected : imgBackground);
         }
     }
 }
Example #5
0
 void Start()
 {
     _receiver = GetComponent <SpoutReceiver>();
 }
 private void OnEnable()
 {
     _spoutReceiver  = GetComponent <SpoutReceiver>();
     inputField.text = _spoutReceiver.nameFilter;
 }