Example #1
0
        private static OSCValue CreateValueButton(object sender)
        {
            var defaultColor = GUI.color;

            EditorGUILayout.BeginHorizontal("box");

            if (!_valueTypeTemp.ContainsKey(sender))
            {
                _valueTypeTemp.Add(sender, OSCValueType.Float);
            }

            _valueTypeTemp[sender] = (OSCValueType)EditorGUILayout.EnumPopup(_valueTypeTemp[sender]);

            GUI.color = Color.green;

            var addButton = GUILayout.Button(_addValueContent, GUILayout.Height(EditorGUIUtility.singleLineHeight));

            if (addButton)
            {
                var value = OSCEditorUtils.CreateOSCValue(_valueTypeTemp[sender]);
                if (value != null)
                {
                    return(value);
                }
                else
                {
                    Debug.LogFormat("[extOSC] You can't add this ({0}) value type!", _valueTypeTemp[sender]);
                }
            }

            GUI.color = defaultColor;
            EditorGUILayout.EndHorizontal();

            return(null);
        }
Example #2
0
        public static string PropertiesPopup(object target, string memberName, Type propertyType, GUIContent content, OSCReflectionAccess access)
        {
            var members   = OSCReflection.GetMembersByType(target, propertyType, access, OSCReflectionType.All);
            var clearName = new List <GUIContent>();

            var currentIndex = 0;

            // GET INDEX
            foreach (var member in members)
            {
                if (member.Name == memberName)
                {
                    currentIndex = clearName.Count;
                }

                clearName.Add(new GUIContent(OSCEditorUtils.MemberName(member)));
            }

            if (clearName.Count == 0)
            {
                clearName.Add(new GUIContent("- None -"));
            }

            currentIndex = EditorGUILayout.Popup(content, currentIndex, clearName.ToArray());
            currentIndex = Mathf.Clamp(currentIndex, 0, clearName.Count - 1);

            return(members.Length > 0 ? members[currentIndex].Name : "- None -");
        }
        private static void InitUIElement <T, K>(CreateCallback createAction,
                                                 OSCWindowControlCreator.ControlData data,
                                                 MenuCommand menuCommand) where K : OSCTransmitterInformer where T : Component
        {
            if (createAction == null)
            {
                return;
            }

            var resources = OSCEditorUtils.GetStandardResources();

            resources.Color = data.ControlColor;

            var element = createAction(resources);

            PlaceUIElement(element, menuCommand);

            if (data.UseInformer)
            {
                AddInformer <K>(element.GetComponent <T>(),
                                data.InformerTransmitter,
                                data.InformAddress,
                                data.InformOnChanged,
                                data.InformInterval);
            }
        }
Example #4
0
        public static OSCReceiver GetReceiver(string settingPath, OSCReceiver defaultReceiver)
        {
            var keyPort = settingPath + ".localport";

            if (!EditorPrefs.HasKey(keyPort))
            {
                return(defaultReceiver);
            }

            var localPort = EditorPrefs.GetInt(settingPath + ".localport", 0);

            return(OSCEditorUtils.FindReceiver(localPort));
        }
        public static OSCTransmitter GetTransmitter(string settingPath, OSCTransmitter defaultTransmitter)
        {
            var keyHost = settingPath + ".remotehost";
            var keyPort = settingPath + ".remoteport";

            if (!EditorPrefs.HasKey(keyHost) || !EditorPrefs.HasKey(keyPort))
            {
                return(defaultTransmitter);
            }

            var remoteHost = EditorPrefs.GetString(keyHost, "");
            var remotePort = EditorPrefs.GetInt(keyPort + ".remoteport", 0);

            return(OSCEditorUtils.FindTransmitter(remoteHost, remotePort));;
        }
        private static void InitMultiplySlidersUIElement(CreateCallback createAction, OSCWindowControlCreator.ControlData data, MenuCommand menuCommand)
        {
            if (createAction == null)
            {
                return;
            }

            var resources = OSCEditorUtils.GetStandardResources();

            resources.Color = data.ControlColor;

            var element = createAction(resources);

            if (data.UseInformer)
            {
                var multiplySliders = element.GetComponent <OSCMultiplySliders>();
                multiplySliders.Address     = data.InformAddress;
                multiplySliders.Transmitter = data.InformerTransmitter;
            }

            PlaceUIElement(element, menuCommand);
        }
Example #7
0
 public static void TransmittersPopup(SerializedProperty property, GUIContent content)
 {
     property.objectReferenceValue = OSCPopup(OSCEditorUtils.GetTransmitters(), property.objectReferenceValue as OSCTransmitter, content);
 }
Example #8
0
 public static OSCTransmitter TransmittersPopup(OSCTransmitter transmitter, GUIContent content)
 {
     return(OSCPopup(OSCEditorUtils.GetTransmitters(), transmitter, content));
 }
Example #9
0
 public static OSCReceiver ReceiversPopup(OSCReceiver receiver, GUIContent content)
 {
     return(OSCPopup(OSCEditorUtils.GetReceivers(), receiver, content));
 }