Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            if (CannotModifyInPlayMode())
            {
                GUI.enabled = false;
            }

            UpdatePrefabModifiedProperties();

            var defaultLabelStyle = EditorStyles.label.fontStyle;

            EditorStyles.label.fontStyle = viewEventPrefabModified
                ? FontStyle.Bold
                : defaultLabelStyle;

            ShowEventMenu(
                UnityEventWatcher.GetBindableEvents(targetScript.gameObject)
                .OrderBy(evt => evt.Name)
                .ToArray(),
                updatedValue => targetScript.ViewEventName = updatedValue,
                targetScript.ViewEventName
                );

            EditorStyles.label.fontStyle = viewModelMethodPrefabModified
                ? FontStyle.Bold
                : defaultLabelStyle;

            ShowMethodMenu(targetScript, TypeResolver.FindBindableMethods(targetScript));

            EditorStyles.label.fontStyle = defaultLabelStyle;
        }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            var targetScript = (EventBinding)target;

            ShowEventMenu(
                UnityEventWatcher.GetBindableEvents(targetScript.gameObject)
                .OrderBy(evt => evt.Name)
                .ToArray(),
                updatedValue => targetScript.uiEventName = updatedValue,
                targetScript.uiEventName
                );

            ShowMethodMenu(targetScript, TypeResolver.FindBindableMethods(targetScript));
        }
Exemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            if (CannotModifyInPlayMode())
            {
                GUI.enabled = false;
            }

            UpdatePrefabModifiedProperties();

            var defaultLabelStyle = EditorStyles.label.fontStyle;

            EditorStyles.label.fontStyle = viewEventPrefabModified
                                ? FontStyle.Bold
                                : defaultLabelStyle;

            ShowEventMenu(
                UnityEventWatcher.GetBindableEvents(targetScript.gameObject)
                .OrderBy(evt => evt.Name)
                .ToArray(),
                updatedValue => targetScript.ViewEventName = updatedValue,
                targetScript.ViewEventName
                );

            EditorStyles.label.fontStyle = viewModelMethodPrefabModified
                                ? FontStyle.Bold
                                : defaultLabelStyle;

            ShowMethodMenu(targetScript, TypeResolver.FindBindableMethods(targetScript));

            if (targetScript.ViewModelMethodName != null)
            {
                var methodName = targetScript.ViewModelMethodName.Split('.');
                if (methodName != null && methodName.Length > 1)
                {
                    var parametersInfos = TypeResolver.FindBindableMethodsParameters(targetScript, methodName[1]);
                    if (parametersInfos != null)
                    {
                        targetScript.Parameter = EditorGUILayout.TextField($"[string only] {parametersInfos.Name} : ", targetScript.Parameter);
                        UpdateProperty(updatedValue => targetScript.Parameter = updatedValue, targetScript.Parameter, targetScript.Parameter, "aezezaeza");
                    }
                }
            }


            EditorStyles.label.fontStyle = defaultLabelStyle;
        }
Exemplo n.º 4
0
        protected override void OnInspector()
        {
            UpdatePrefabModifiedProperties();

            EditorStyles.label.fontStyle = viewEventPrefabModified
                ? FontStyle.Bold
                : DefaultFontStyle;

            ShowEventMenu(
                UnityEventWatcher.GetBindableEvents(targetScript.gameObject)
                .OrderBy(evt => evt.Name)
                .ToArray(),
                updatedValue => targetScript.ViewEventName = updatedValue,
                targetScript.ViewEventName
                );

            EditorStyles.label.fontStyle = viewModelMethodPrefabModified
                ? FontStyle.Bold
                : DefaultFontStyle;

            ShowMethodMenu(targetScript, TypeResolver.FindBindableMethods(targetScript));
        }
Exemplo n.º 5
0
    // Start is called before the first frame update
    public override void OnInspectorGUI()
    {
        if (CannotModifyInPlayMode())
        {
            GUI.enabled = false;
        }

        UpdatePrefabModifiedProperties();

        var availableMessagesTypes = TypeResolver.TypesWithMessageAttribute.OrderBy(message => message.ToString()).ToArray();
        var availableMessages      = availableMessagesTypes.Select(type => type.ToString())
                                     .ToArray();

        targetScript.UnityEditorSelectedMessageTypeIndex = Array.IndexOf(
            availableMessages,
            targetScript.UnityEditorSelectedMessageName
            );

        var defaultLabelStyle = EditorStyles.label.fontStyle;

        EditorStyles.label.fontStyle = viewModelMethodPrefabModified
               ? FontStyle.Bold
               : defaultLabelStyle;

        var newSelectedIndex = EditorGUILayout.Popup(
            new GUIContent("MessageType", "Type of the view model that this template will be bound to when it is instantiated."),
            targetScript.UnityEditorSelectedMessageTypeIndex,
            availableMessages
            .Select(viewModel => new GUIContent(viewModel))
            .ToArray());

        EditorStyles.label.fontStyle = defaultLabelStyle;
        if (newSelectedIndex >= 0)
        {
            var newSelectedType = (Type)availableMessagesTypes[newSelectedIndex];
            targetScript.UnityEditorSelectedMessageName = newSelectedType.ToString();
        }

        // Don't let the user set anything else until they've chosen a view property.
        var guiPreviouslyEnabled = GUI.enabled;

        if (string.IsNullOrEmpty(targetScript.UnityEditorSelectedMessageName))
        {
            GUI.enabled = false;
            return;
        }


        var bindableMethods = TypeResolver.FindBindableMethods(targetScript, (Type)availableMessagesTypes[newSelectedIndex]);

        InspectorUtils.DoPopup(
            new GUIContent(targetScript.UnityEditorViewModelMethodHandler),
            new GUIContent("View-model method", ""),
            m => m.ViewModelType + "/" + m.MemberName,
            m => true,
            m => m.ToString() == targetScript.UnityEditorViewModelMethodHandler,
            m =>
        {
            UpdateProperty(
                updatedValue =>
            {
                targetScript.UnityEditorViewModelMethodHandler = updatedValue;
            },
                targetScript.UnityEditorViewModelMethodHandler,
                m.ToString(),
                "Set bound view-model method"
                );
        },
            bindableMethods
            .OrderBy(m => m.ViewModelTypeName)
            .ThenBy(m => m.MemberName)
            .ToArray()
            );
    }