//----------------------------------- end of public functions --------------------------------------// //void Awake() //{ // instance = this; //} public void Start() { try { // get sensor data kinectManager = KinectManager.Instance; if (kinectManager && kinectManager.IsInitialized()) { sensorData = kinectManager.GetSensorData(sensorIndex); } if (sensorData == null || sensorData.sensorInterface == null) { throw new Exception("Background removal cannot be started, because KinectManager is missing or not initialized."); } if (foregroundImage == null) { // look for a foreground image foregroundImage = GetComponent <UnityEngine.UI.RawImage>(); } if (!foregroundCamera) { // by default - the main camera foregroundCamera = Camera.main; } // try to get reference to other filter components filterByBody = GetComponent <BackgroundRemovalByBodyBounds>(); if (filterByBody == null) { filterByDist = GetComponent <BackgroundRemovalByDist>(); } if (filterByBody == null && filterByDist == null) { filterByBI = GetComponent <BackgroundRemovalByBodyIndex>(); } if (filterByBody == null && filterByDist == null && filterByBI == null) { filterByGS = GetComponent <BackgroundRemovalByGreenScreen>(); } if (filterByBody == null && filterByDist == null && filterByBI == null && filterByGS == null) { filterByBI = gameObject.AddComponent <BackgroundRemovalByBodyIndex>(); // fallback } // Initialize the background removal bool bSuccess = InitBackgroundRemoval(sensorData); if (bSuccess) { if (debugText != null) { debugText.text = string.Empty; } } else { throw new Exception("Background removal could not be initialized."); } bBackgroundRemovalInited = bSuccess; } catch (DllNotFoundException ex) { Debug.LogError(ex.ToString()); if (debugText != null) { debugText.text = "Please check the SDK installations."; } } catch (Exception ex) { Debug.LogException(ex); if (debugText != null) { debugText.text = ex.Message; } } }