Esempio n. 1
0
        internal static void DrawSelectObjectEditor(IExpressionInspector inode)
        {
            var otypes            = GetDerivedTypeInfo(typeof(UnityEngine.Object));
            var typeName          = inode.GetProperty <string>("type", null);
            var selectedTypeIndex = otypes.names.FindIndex(n => n == typeName);
            var typeLabel         = selectedTypeIndex == -1 ? null : otypes.labels[selectedTypeIndex];

            inode.DrawSelectionPopup("Type", typeLabel ?? "Select type...", otypes.labels, selectedIndex => inode.SetProperty("type", otypes.names[selectedIndex]));
            if (typeName != null)
            {
                if (selectedTypeIndex != -1)
                {
                    var selectedType  = otypes.types[selectedTypeIndex];
                    var properties    = GetTypePropertyNames(selectedType);
                    var propertyName  = inode.GetProperty <string>("field", null);
                    var propertyLabel = properties.FirstOrDefault(p => p.name == propertyName).label;

                    inode.DrawSelectionPopup("Property", propertyLabel ?? "Select property...", properties.Select(p => p.label), selectedIndex =>
                    {
                        inode.SetProperty("field", properties[selectedIndex].name);
                    });
                }
            }

            DrawMappedControl(inode);
        }
Esempio n. 2
0
        internal static void DrawSelectReferencesEditor(IExpressionInspector m_Node)
        {
            var refPropertyType = m_Node.GetProperty("type", "");
            var refDepth        = m_Node.GetProperty("depth", 1);

            EditorGUI.BeginChangeCheck();
            refPropertyType = EditorGUILayout.DelayedTextField("Type", refPropertyType);
            refDepth        = EditorGUILayout.IntSlider("Depth", refDepth, 0, 9);
            if (EditorGUI.EndChangeCheck())
            {
                m_Node.SetProperty("type", refPropertyType);
                m_Node.SetProperty("depth", refDepth);
            }
        }
Esempio n. 3
0
        private static void DrawMappedControl(IExpressionInspector m_Node)
        {
            EditorGUI.BeginChangeCheck();
            var mapped = EditorGUILayout.Toggle("Mapped", m_Node.GetProperty(ExpressionKeyName.Mapped, false));

            if (EditorGUI.EndChangeCheck())
            {
                m_Node.SetProperty(ExpressionKeyName.Mapped, mapped);
            }
        }
Esempio n. 4
0
        internal static void DrawSelectComponentEditor(IExpressionInspector inode)
        {
            var ctypes            = GetDerivedTypeInfo(typeof(Component));
            var typeName          = inode.GetProperty <string>("type", null);
            var selectedTypeIndex = ctypes.names.FindIndex(n => n == typeName);
            var typeLabel         = selectedTypeIndex == -1 ? null : ctypes.labels[selectedTypeIndex];

            inode.DrawSelectionPopup("Type", typeLabel ?? "Select type...", ctypes.labels, selectedIndex => inode.SetProperty("type", ctypes.names[selectedIndex]));
            if (typeName != null)
            {
                if (selectedTypeIndex != -1)
                {
                    var selectedType  = ctypes.types[selectedTypeIndex];
                    var properties    = GetTypePropertyNames(selectedType);
                    var propertyName  = inode.GetProperty <string>("field", null);
                    var propertyLabel = properties.FirstOrDefault(p => p.name == propertyName).label;

                    inode.DrawSelectionPopup("Property", propertyLabel ?? "Select property...", properties.Select(p => p.label), selectedIndex =>
                    {
                        inode.SetProperty("field", properties[selectedIndex].name);
                    });
                }
            }

            EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginChangeCheck();
            var originalSource = EditorGUILayout.Toggle("Overrides", inode.GetProperty(ExpressionKeyName.Overrides, true));

            if (EditorGUI.EndChangeCheck())
            {
                inode.SetProperty(ExpressionKeyName.Overrides, originalSource);
            }

            DrawMappedControl(inode);

            EditorGUILayout.EndHorizontal();
        }