// Use this for initialization void Awake() { //Get the shared texture camera on this object _myCam = GetComponent <Camera>(); if (!this.isActiveAndEnabled) { return; } #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN this.gameObject.SetActive(false); //to prevent awake method to execute before its variable initialization spout = gameObject.AddComponent <Klak.Spout.SpoutSender>(); spout.useCamera = false; spout.sourceTexture = texture; spout.senderName = sharingName; spout.alphaSupport = alphaSupport; NewTextureSize(outputWidth, outputHeight); #endif #if UNITY_EDITOR_MAC || UNITY_STANDALONE_OSX this.gameObject.SetActive(false); funnel = gameObject.AddComponent <Funnel.Funnel>(); //to prevent awake method to execute before its variable initialization funnel.antiAliasing = antiAliasing; funnel.discardAlpha = discardAlpha; funnel.renderMode = renderMode; #endif this.gameObject.SetActive(true); isSendingTexture = true; this.enabled = SpoutOutput; }
private void OnEnable() { sender = GetComponent <SpoutSender>(); targetCamera = GetComponent <Camera>(); targetTex = new ResizableRenderTexture(); validator.Reset(); validator.Validation += () => { Debug.LogFormat("Update Spout : {0}", data); SetTargetTexture(null); guidata = new GUIData(data); var frt = new FormatRT() { textureFormat = format, depth = 24, useMipMap = false, antiAliasing = QualitySettings.antiAliasing, readWrite = RenderTextureReadWrite.Default, filterMode = FilterMode.Bilinear, wrapMode = TextureWrapMode.Clamp, anisoLevel = 0 }; if (sender != null) { sender.enabled = data.spout; } if (data.spout) { targetTex.Format = frt; targetTex.Size = data.Size; SetTargetTexture(targetTex); } else { targetTex.Release(); } events.ActiveOnEnabled.Invoke(data.spout); events.ActiveOnDisabled.Invoke(!data.spout); }; Load(); validator.Validate(); }