public MouseHandler(INativePlatform nativePlatform) { this.nativePlatform = nativePlatform; this.nativePlatform.InputEvents.MouseDown.Add(this.OnMouseDown); this.nativePlatform.InputEvents.MouseUp.Add(this.OnMouseUp); this.nativePlatform.InputEvents.MouseMove.Add(this.OnMouseMove); }
public KeyboardHandler(EditorContext editorContext) { this.actions = editorContext.Actions; this.editorState = editorContext.EditorState; this.xmlRules = editorContext.XmlRules; this.nativePlatform = editorContext.NativePlatform; this.nativePlatform.InputEvents.PreviewKey.Add(this.ControlKeyPreview); }
/// <summary> /// Initialize the detector /// </summary> /// <param name="discrete">If the frames processed as discrete images</param> public void Initialize(bool discrete = false) { if (_initialized) return; // Libraries are expected in Assets/Affdex/Plugins String rootPath; if (RuntimePlatform.OSXPlayer == Application.platform || RuntimePlatform.WindowsPlayer == Application.platform) rootPath = Application.dataPath; else rootPath = Path.Combine (Application.dataPath, "Affdex"); rootPath = Path.Combine (rootPath, "Plugins"); Debug.Log ("Starting affdex SDK using (" + Application.platform + ") Platform"); //use Application.platform to determine platform if (RuntimePlatform.WindowsEditor == Application.platform || RuntimePlatform.WindowsPlayer == Application.platform) { if (IntPtr.Size == 8 && RuntimePlatform.WindowsEditor == Application.platform) { rootPath = Path.Combine(rootPath, "x86_64"); } else if (RuntimePlatform.WindowsEditor == Application.platform) { rootPath = Path.Combine(rootPath, "x86"); } LoadNativeDll (Path.Combine (rootPath, "affdex-native.dll")); LoadNativeDll (Path.Combine (rootPath, "AffdexNativeWrapper.dll")); nativePlatform = new WindowsNativePlatform (); } else if (RuntimePlatform.OSXEditor == Application.platform || RuntimePlatform.OSXPlayer == Application.platform) { if (!LoadNativeDll (Path.Combine (rootPath, "affdex-native.bundle/Contents/MacOS/affdex-native"))) return; nativePlatform = new OSXNativePlatform (); } //todo: Handle INitialize failure here! nativePlatform.Initialize (this, discrete ? 1 : 0); //find all ON emotions and enable them! for (int i = 0; i < System.Enum.GetNames (typeof(Emotions)).Length; i++) { Emotions targetEmotion = (Emotions)i; if (emotions.On (targetEmotion)) { //Debug.Log(targetEmotion + " is on"); nativePlatform.SetEmotionState (i, true); } } //find all ON emotions and enable them! for (int i = 0; i < System.Enum.GetNames (typeof(Expressions)).Length; i++) { Expressions targetExpression = (Expressions)i; if (expressions.On (targetExpression)) { //Debug.Log(targetExpression + " is on"); nativePlatform.SetExpressionState (i, true); } } _initialized = true; }
/// <summary> /// Initialize the detector /// </summary> /// <param name="discrete">If the frames processed as discrete images</param> public void Initialize(bool discrete = false) { if (_initialized) { return; } // Libraries are expected in Assets/Affdex/Plugins String rootPath; if (RuntimePlatform.OSXPlayer == Application.platform) { rootPath = Application.dataPath; } else { rootPath = Path.Combine(Application.dataPath, "Affdex"); } rootPath = Path.Combine(rootPath, "Plugins"); Debug.Log("Starting affdex SDK using (" + Application.platform + ") Platform"); //use Application.platform to determine platform if (RuntimePlatform.WindowsEditor == Application.platform || RuntimePlatform.WindowsPlayer == Application.platform) { rootPath = Path.Combine(rootPath, "x86_64"); LoadNativeDll(Path.Combine(rootPath, "affdex-native.dll")); LoadNativeDll(Path.Combine(rootPath, "AffdexNativeWrapper.dll")); nativePlatform = new WindowsNativePlatform(); } else if (RuntimePlatform.OSXEditor == Application.platform || RuntimePlatform.OSXPlayer == Application.platform) { if (!LoadNativeDll(Path.Combine(rootPath, "affdex-native.bundle/Contents/MacOS/affdex-native"))) { return; } nativePlatform = new OSXNativePlatform(); } //todo: Handle INitialize failure here! nativePlatform.Initialize(this, discrete ? 1 : 0); //find all ON emotions and enable them! for (int i = 0; i < System.Enum.GetNames(typeof(Emotions)).Length; i++) { Emotions targetEmotion = (Emotions)i; if (emotions.On(targetEmotion)) { //Debug.Log(targetEmotion + " is on"); nativePlatform.SetEmotionState(i, true); } } //find all ON emotions and enable them! for (int i = 0; i < System.Enum.GetNames(typeof(Expressions)).Length; i++) { Expressions targetExpression = (Expressions)i; if (expressions.On(targetExpression)) { //Debug.Log(targetExpression + " is on"); nativePlatform.SetExpressionState(i, true); } } _initialized = true; }