예제 #1
0
        private void CreateMapValue(OSCMapMessage mapMessage, OSCMapType mapType)
        {
            var mapValue = new OSCMapValue();

            mapValue.Type = mapType;

            if (mapType == OSCMapType.FloatToBool)
            {
                mapValue.Value = 0.5f;
            }
            else if (mapType == OSCMapType.IntToBool)
            {
                mapValue.Value = 1;
            }

            mapMessage.Values.Add(mapValue);
        }
    void Update()
    {
        ProcessPendingInputMessages();

        for (int i = 0; i < OSCQueue.Count; i++)
        {
            OSCMapMessage oscMsg = OSCQueue.Dequeue();
            ProcessOSCIn(oscMsg.m_Address, oscMsg.m_Value);
        }

        if (!m_UsePeriodicOutput || m_OutputTimer <= 0.0f)
        {
            OutputCurrentState();
            m_OutputTimer = m_OutputStatePeriod;
        }
        else
        {
            m_OutputTimer -= Time.deltaTime;
        }
    }
예제 #3
0
        private void DrawMapMessage(OSCMapMessage mapMessage, bool expand)
        {
            EditorGUILayout.BeginVertical("box");

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(_addressContent);
            GUI.color = Color.red;
            var deleteButton = GUILayout.Button("x", GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.Width(20));

            if (deleteButton)
            {
                _deleteMessage = mapMessage;
            }
            GUI.color = _defaultColor;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal("box");
            mapMessage.Address = EditorGUILayout.TextField(mapMessage.Address);
            EditorGUILayout.EndHorizontal();

            if (mapMessage.Values.Count > 0)
            {
                GUILayout.Label(_valuesContent);

                _deleteValue = null;

                foreach (var mapValue in mapMessage.Values)
                {
                    DrawMapValue(mapValue, expand);
                }

                if (_deleteValue != null)
                {
                    mapMessage.Values.Remove(_deleteValue);
                }
            }
            else
            {
                GUILayout.Label(_valuesContent);
                EditorGUILayout.BeginVertical("box");
                EditorGUILayout.LabelField("- Empty -", OSCEditorStyles.CenterLabel);
                EditorGUILayout.EndVertical();
            }

            if (!_mapTypeTemp.ContainsKey(mapMessage))
            {
                _mapTypeTemp.Add(mapMessage, OSCMapType.Float);
            }

            EditorGUILayout.BeginHorizontal("box");

            _mapTypeTemp[mapMessage] = (OSCMapType)EditorGUILayout.EnumPopup(_mapTypeTemp[mapMessage]);

            GUI.color = Color.green;
            var addButton = GUILayout.Button(_addMapValueContent, GUILayout.Height(EditorGUIUtility.singleLineHeight));

            if (addButton)
            {
                CreateMapValue(mapMessage, _mapTypeTemp[mapMessage]);
            }
            GUI.color = _defaultColor;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }
예제 #4
0
        protected override void DrawContent(Rect contentRect)
        {
            _defaultColor = GUI.color;

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            var createMapButton = GUILayout.Button(_createContent, EditorStyles.toolbarButton);

            GUILayout.Space(5);

            if (GUILayout.Button(_openContent, EditorStyles.toolbarDropDown))
            {
                GUIContent[] popupItems;
                string[]     patches;

                GetMappingAssets(out popupItems, out patches);

                var customMenuRect = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0);

                EditorUtility.DisplayCustomMenu(customMenuRect, popupItems, -1, OpenMapBundle, patches);
            }

            GUILayout.FlexibleSpace();

            if (_currentMapBundle != null)
            {
                GUILayout.Label(string.Format("Name: {0}", _currentMapBundle.name));
            }

            EditorGUILayout.EndHorizontal();

            var expand = contentRect.width > 810;

            if (_currentMapBundle != null)
            {
                _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);

                GUILayout.Label(string.Format("Path: {0}", AssetDatabase.GetAssetPath(_currentMapBundle)));

                if (_currentMapBundle.Messages.Count > 0)
                {
                    _deleteMessage = null;

                    foreach (var mapMessage in _currentMapBundle.Messages)
                    {
                        DrawMapMessage(mapMessage, expand);
                    }

                    if (_deleteMessage != null)
                    {
                        _currentMapBundle.Messages.Remove(_deleteMessage);
                    }
                }
                else
                {
                    EditorGUILayout.BeginHorizontal("box");
                    GUILayout.Label(_emptyContent, OSCEditorStyles.CenterLabel);
                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.BeginHorizontal("box");
                GUI.color = Color.green;
                var createMessageButton = GUILayout.Button(_addAddressContent);
                GUI.color = _defaultColor;
                EditorGUILayout.EndHorizontal();

                if (createMessageButton)
                {
                    _currentMapBundle.Messages.Add(new OSCMapMessage()
                    {
                        Address = "/address/" + _currentMapBundle.Messages.Count
                    });
                }
                if (_deleteMessage != null)
                {
                    _currentMapBundle.Messages.Remove(_deleteMessage);
                }

                EditorGUILayout.EndScrollView();
            }
            else
            {
                EditorGUILayout.LabelField(_infoContent, OSCEditorStyles.CenterLabel, GUILayout.Height(contentRect.height));
            }

            if (createMapButton)
            {
                CreateMapBundle();
            }
        }