예제 #1
0
 private void DrawObjectsToEnableList()
 {
     ReorderableListGUI.Title("Objects to enable");
     ReorderableListGUI.ListField(objectsToEnable);
 }
예제 #2
0
        public override void OnLayoutEnable()
        {
            base.OnLayoutEnable();

            ISD_CapabilityLayout layout;

            m_CapabilitiesLayout = new List <ISD_CapabilityLayout>();

            //iCloud


            layout = new ISD_CapabilityLayout("iCloud", "cloud.png", () => { return(ISD_Settings.Instance.Capability.iCloud); }, () => {
                using (new SA_GuiHorizontalSpace(16)) {
                    var cloud             = ISD_Settings.Instance.Capability.iCloud;
                    cloud.keyValueStorage = SA_EditorGUILayout.ToggleFiled("Key Value Storage", cloud.keyValueStorage, SA_StyledToggle.ToggleType.EnabledDisabled);
                    cloud.iCloudDocument  = SA_EditorGUILayout.ToggleFiled("iCloud Document", cloud.iCloudDocument, SA_StyledToggle.ToggleType.EnabledDisabled);

                    ReorderableListGUI.Title("Custom Containers");
                    ReorderableListGUI.ListField(cloud.customContainers, (Rect position, string itemValue) => {
                        return(EditorGUI.TextField(position, itemValue));
                    }, () => {
                        GUILayout.Label("You haven't added any custom containers yet.");
                    });
                }
            });

            m_CapabilitiesLayout.Add(layout);


            //Push Notifications

            layout = new ISD_CapabilityLayout("Push Notifications", "push.png", () => { return(ISD_Settings.Instance.Capability.PushNotifications); }, () => {
                using (new SA_GuiHorizontalSpace(16)) {
                    var pushNotifications         = ISD_Settings.Instance.Capability.PushNotifications;
                    pushNotifications.development = SA_EditorGUILayout.ToggleFiled("Development", pushNotifications.development, SA_StyledToggle.ToggleType.YesNo);
                }
            });

            m_CapabilitiesLayout.Add(layout);


            //Game Center
            layout = new ISD_CapabilityLayout("Game Center", "game.png", () => { return(ISD_Settings.Instance.Capability.GameCenter); }, () => { });
            m_CapabilitiesLayout.Add(layout);

            //Wallet

            layout = new ISD_CapabilityLayout("Wallet", "wallet.png", () => { return(ISD_Settings.Instance.Capability.Wallet); }, () => {
                var wallet = ISD_Settings.Instance.Capability.Wallet;
                using (new SA_GuiBeginHorizontal()) {
                    GUILayout.Space(16);
                    using (new SA_GuiBeginVertical()) {
                        ReorderableListGUI.Title("Pass Subset");
                        ReorderableListGUI.ListField(wallet.passSubset, (Rect position, string itemValue) => {
                            return(EditorGUI.TextField(position, itemValue));
                        }, () => {
                            GUILayout.Label("You haven't added any pass subset.");
                        });
                    }
                }
            });
            m_CapabilitiesLayout.Add(layout);


            //Siri
            layout = new ISD_CapabilityLayout("Siri", "siri.png", () => { return(ISD_Settings.Instance.Capability.Siri); }, () => { });
            m_CapabilitiesLayout.Add(layout);


            //ApplePay

            layout = new ISD_CapabilityLayout("Apple Pay", "pay.png", () => { return(ISD_Settings.Instance.Capability.ApplePay); }, () => {
                var applePay = ISD_Settings.Instance.Capability.ApplePay;
                using (new SA_GuiBeginHorizontal()) {
                    GUILayout.Space(16);
                    using (new SA_GuiBeginVertical()) {
                        ReorderableListGUI.Title("Merchants");
                        ReorderableListGUI.ListField(applePay.merchants, (Rect position, string itemValue) => {
                            return(EditorGUI.TextField(position, itemValue));
                        }, () => {
                            GUILayout.Label("You haven't added any merchants yet.");
                        });
                    }
                }
            });
            m_CapabilitiesLayout.Add(layout);


            //InAppPurchase
            layout = new ISD_CapabilityLayout("In-App Purchase", "purchase.png", () => { return(ISD_Settings.Instance.Capability.InAppPurchase); }, () => { });
            m_CapabilitiesLayout.Add(layout);


            //Maps
            layout = new ISD_CapabilityLayout("Maps", "maps.png", () => { return(ISD_Settings.Instance.Capability.Maps); }, () => {
                var maps = ISD_Settings.Instance.Capability.Maps;
                using (new SA_GuiBeginHorizontal()) {
                    GUILayout.Space(16);
                    using (new SA_GuiBeginVertical()) {
                        ReorderableListGUI.Title("Options");
                        ReorderableListGUI.ListField(maps.options, (Rect position, ISD_CapabilitySettings.MapsCapability.MapsOptions itemValue) => {
                            return((ISD_CapabilitySettings.MapsCapability.MapsOptions)EditorGUI.EnumPopup(position, itemValue));
                        }, () => {
                            GUILayout.Label("Set maps capability options.");
                        });
                    }
                }
            });
            m_CapabilitiesLayout.Add(layout);

            //PersonalVPN
            layout = new ISD_CapabilityLayout("Personal VPN", "vpn.png", () => { return(ISD_Settings.Instance.Capability.PersonalVPN); }, () => { });
            m_CapabilitiesLayout.Add(layout);


            //BackgroundModes
            layout = new ISD_CapabilityLayout("Background Modes", "back.png", () => { return(ISD_Settings.Instance.Capability.BackgroundModes); }, () => {
                var backgroundModes = ISD_Settings.Instance.Capability.BackgroundModes;

                using (new SA_GuiBeginHorizontal()) {
                    GUILayout.Space(16);
                    using (new SA_GuiBeginVertical()) {
                        ReorderableListGUI.Title("Options");
                        ReorderableListGUI.ListField(backgroundModes.options, (Rect position, ISD_CapabilitySettings.BackgroundModesCapability.BackgroundModesOptions itemValue) => {
                            return((ISD_CapabilitySettings.BackgroundModesCapability.BackgroundModesOptions)EditorGUI.EnumPopup(position, itemValue));
                        }, () => {
                            GUILayout.Label("Set background modes capability options.");
                        });
                    }
                }
            });
            m_CapabilitiesLayout.Add(layout);


            //InterAppAudio
            layout = new ISD_CapabilityLayout("Inter-App Audio", "inter.png", () => { return(ISD_Settings.Instance.Capability.InterAppAudio); }, () => { });
            m_CapabilitiesLayout.Add(layout);


            //KeychainSharing
            layout = new ISD_CapabilityLayout("Keychain Sharing", "keychaine.png", () => { return(ISD_Settings.Instance.Capability.KeychainSharing); }, () => {
                var keychainSharing = ISD_Settings.Instance.Capability.KeychainSharing;

                using (new SA_GuiBeginHorizontal()) {
                    GUILayout.Space(16);
                    using (new SA_GuiBeginVertical()) {
                        ReorderableListGUI.Title("Access Groups");
                        ReorderableListGUI.ListField(keychainSharing.accessGroups, (Rect position, string itemValue) => {
                            return(EditorGUI.TextField(position, itemValue));
                        }, () => {
                            GUILayout.Label("You haven't added any access groups yet.");
                        });
                    }
                }
            });
            m_CapabilitiesLayout.Add(layout);


            //AssociatedDomains
            layout = new ISD_CapabilityLayout("Associated Domains", "associated.png", () => { return(ISD_Settings.Instance.Capability.AssociatedDomains); }, () => {
                var associatedDomains = ISD_Settings.Instance.Capability.AssociatedDomains;

                using (new SA_GuiBeginHorizontal()) {
                    GUILayout.Space(16);
                    using (new SA_GuiBeginVertical()) {
                        ReorderableListGUI.Title("Associated Domains");
                        ReorderableListGUI.ListField(associatedDomains.domains, (Rect position, string itemValue) => {
                            return(EditorGUI.TextField(position, itemValue));
                        }, () => {
                            GUILayout.Label("You haven't added any domains yet.");
                        });
                    }
                }
            });
            m_CapabilitiesLayout.Add(layout);

            //AssociatedDomains
            layout = new ISD_CapabilityLayout("App Groups", "app.png", () => { return(ISD_Settings.Instance.Capability.AppGroups); }, () => {
                var appGroups = ISD_Settings.Instance.Capability.AppGroups;

                using (new SA_GuiBeginHorizontal()) {
                    GUILayout.Space(16);
                    using (new SA_GuiBeginVertical()) {
                        ReorderableListGUI.Title("Groups");
                        ReorderableListGUI.ListField(appGroups.groups, (Rect position, string itemValue) => {
                            return(EditorGUI.TextField(position, itemValue));
                        }, () => {
                            GUILayout.Label("You haven't added any groups yet.");
                        });
                    }
                }
            });
            m_CapabilitiesLayout.Add(layout);



            //InterAppAudio
            layout = new ISD_CapabilityLayout("Data Protection", "data.png", () => { return(ISD_Settings.Instance.Capability.DataProtection); }, () => { });
            m_CapabilitiesLayout.Add(layout);


            //InterAppAudio
            layout = new ISD_CapabilityLayout("HomeKit", "homekit.png", () => { return(ISD_Settings.Instance.Capability.HomeKit); }, () => { });
            m_CapabilitiesLayout.Add(layout);

            //InterAppAudio
            layout = new ISD_CapabilityLayout("HealthKit", "healhtkit.png", () => { return(ISD_Settings.Instance.Capability.HealthKit); }, () => { });
            m_CapabilitiesLayout.Add(layout);

            //InterAppAudio
            layout = new ISD_CapabilityLayout("Wireless Accessory Configuration", "wirelless.png", () => { return(ISD_Settings.Instance.Capability.WirelessAccessoryConfiguration); }, () => { });
            m_CapabilitiesLayout.Add(layout);
        }
예제 #3
0
        private void OnGUI()
        {
            if (_indexLabelSkin == null)
            {
                _indexLabelSkin = new GUIStyle(GUI.skin.label)
                {
                    alignment = TextAnchor.MiddleRight
                };
            }

            GUILayout.Space(10f);
            this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition);

            if (GUILayout.Button(LOCATE_CREATE_LABEL))
            {
                TypeDataDictionary.LocateOrCreateAsset();
                this.dictionary        = Selection.activeObject as TypeDataDictionary;
                Selection.activeObject = null;
                this.savedTypes        = this.dictionary.GetSavedTypes();
                this.includeEmptyNamespaceTypesProperty.boolValue = this.dictionary.IncludeEmptyNamespaceTypes;

                var namespaces = this.dictionary.CustomNamespaces;
                this.customNamespacesProperty.arraySize = namespaces.Count;
                this.customNamespacesProperty.ClearArray();

                for (var i = 0; i < namespaces.Count; i++)
                {
                    this.customNamespacesProperty.InsertArrayElementAtIndex(i);
                    this.customNamespacesProperty.GetArrayElementAtIndex(i).stringValue = namespaces[i];
                }
            }

            if (this.dictionary != null)
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField(NAMESPACE_SETTINGS_LABEL, EditorStyles.boldLabel);
                EditorGUILayout.TextField(DEFAULT_NAMESPACE_LABEL, TypeExtension.UNITY_NAMESPACE);
                EditorGUILayout.PropertyField(this.includeEmptyNamespaceTypesProperty, EmptyNamespaceLabel, true);

                ReorderableListGUI.Title(CUSTOM_NAMESPACES_LABEL);
                ReorderableListGUI.ListField(this.customNamespacesProperty, ReorderableListFlags.ShowIndices);

                if (GUILayout.Button(NAMESPACE_BUTTON_LABEL))
                {
                    Selection.activeObject = this.dictionary;
                    this.dictionary.SetIncludeEmptyNamespaceTypes(this.includeEmptyNamespaceTypesProperty.boolValue);

                    this.customNamespaces.Clear();

                    for (var i = 0; i < this.customNamespacesProperty.arraySize; i++)
                    {
                        var customNamespace = this.customNamespacesProperty.GetArrayElementAtIndex(i).stringValue;
                        this.customNamespaces.Add(customNamespace);
                    }

                    this.dictionary.SetCustomNamespaces(this.customNamespaces);
                }

                GUILayout.BeginHorizontal();
                if (GUILayout.Button(UPDATE_BUTTON_LABEL))
                {
                    Selection.activeObject = this.dictionary;
                    this.dictionary.UpdateData();
                    this.savedTypes = this.dictionary.GetSavedTypes();
                }

                if (GUILayout.Button(CLEAR_BUTTON_LABEL))
                {
                    Selection.activeObject = this.dictionary;
                    this.dictionary.ClearData();
                    this.savedTypes = this.dictionary.GetSavedTypes();
                }
                GUILayout.EndHorizontal();

                Selection.activeObject = null;
            }

            EditorGUILayout.Space();
            var length = this.savedTypes == null ? 0 : this.savedTypes.Length;

            EditorGUILayout.LabelField(string.Format("Types [{0}]", length), EditorStyles.boldLabel);
            this.showTypeList = EditorGUILayout.Foldout(this.showTypeList, "");

            if (length > 0 && this.showTypeList)
            {
                GUILayout.Space(5f);
                for (var i = 0; i < this.savedTypes.Length; i++)
                {
                    var names = this.savedTypes[i];

                    GUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(i.ToString(), _indexLabelSkin, GUILayout.MaxWidth(50f));

                    for (var n = 0; n < names.Length; n++)
                    {
                        EditorGUILayout.TextField(names[n]);
                    }

                    GUILayout.EndHorizontal();
                }
            }

            GUILayout.EndScrollView();
            GUILayout.Space(10f);
        }
예제 #4
0
    //=====================================================

    public override void OnInspectorGUI()
    {
        _serializedTarget.Update();
        // Set / display all coded defaults
        //base.OnInspectorGUI();

        EditorGUILayout.Space();
        switch (_myTarget.Type)
        {
        case ePlatformType.ON_PATH:
            EditorGUILayout.LabelField("Platform Type: ", "On Path");
            break;

        case ePlatformType.ON_SPLINE:
            EditorGUILayout.LabelField("Platform Type: ", "On Spline");
            break;
        }

        // Switch Model
        EditorGUILayout.Space();
        _myTarget.Model = EditorGUILayout.Popup("Platform Model", _myTarget.Model, _models);

        // Path Parameter - one_shot, ping_pong, loop
        EditorGUILayout.Space();
        _pathParameter.enumValueIndex = (int)(Platform.ePathParameter)EditorGUILayout.EnumPopup("Path Parameter",
                                                                                                (Platform.ePathParameter)Enum.ToObject(typeof(Platform.ePathParameter), _pathParameter.enumValueIndex));

        // Platform Speed
        EditorGUILayout.Space();
        switch (_myTarget.Type)
        {
        case ePlatformType.ON_PATH:
            _myTarget.DurationNodeToNode = (float)EditorGUILayout.IntSlider("Time: Between Nodes", (int)_myTarget.DurationNodeToNode, 1, 20);
            break;

        case ePlatformType.ON_SPLINE:
            _myTarget.DurationStartToEnd = (float)EditorGUILayout.IntSlider("Time: Start To End", (int)_myTarget.DurationStartToEnd, 1, 20);
            break;
        }

        // Path Nodes
        ReorderableListGUI.Title("Path Nodes");
        ReorderableListGUI.ListField(_pathNodes, ReorderableListFlags.ShowIndices);

        // Platform Switches
        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(_switches, new GUIContent("Platform Switches"), true);

        var autoRefresh = false;

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
            EditorUtility.SetDirty(_myTarget);

            autoRefresh = true;
        }

        // Refresh serialized parameters
        _serializedTarget.ApplyModifiedProperties();

        if (autoRefresh)
        {
            _myTarget.Refresh();
        }
    }
예제 #5
0
 /// <summary>
 /// Draws the given array type using a reorderable list drawer
 /// </summary>
 /// <param name="property"></param>
 /// <param name="label"></param>
 public static void DrawReorderableList <T>(List <T> list, string label, ReorderableListControl.ItemDrawer <T> drawItem)
 {
     ReorderableListGUI.Title(label);
     ReorderableListGUI.ListField(list, drawItem);
 }
예제 #6
0
        public virtual void DrawVariablesGUI()
        {
            serializedObject.Update();

            FungusScript t = target as FungusScript;

            if (t.variables.Count == 0)
            {
                t.variablesExpanded = true;
            }

            if (!t.variablesExpanded)
            {
                if (GUILayout.Button("Variables (" + t.variables.Count + ")", GUILayout.Height(24)))
                {
                    t.variablesExpanded = true;
                }
            }
            else
            {
                Rect listRect = new Rect();

                if (t.variables.Count > 0)
                {
                    ReorderableListGUI.Title("Variables");
                    VariableListAdaptor adaptor = new VariableListAdaptor(variablesProp, 0);

                    ReorderableListFlags flags = ReorderableListFlags.DisableContextMenu | ReorderableListFlags.HideAddButton;

                    ReorderableListControl.DrawControlFromState(adaptor, null, flags);
                    listRect = GUILayoutUtility.GetLastRect();
                }
                else
                {
                    GUILayoutUtility.GetRect(300, 24);
                    listRect    = GUILayoutUtility.GetLastRect();
                    listRect.y += 20;
                }

                float plusWidth  = 32;
                float plusHeight = 24;

                Rect  buttonRect   = listRect;
                float buttonHeight = 24;
                buttonRect.x      = 4;
                buttonRect.y     -= buttonHeight - 1;
                buttonRect.height = buttonHeight;
                if (!Application.isPlaying)
                {
                    buttonRect.width -= 30;
                }

                if (GUI.Button(buttonRect, "Variables"))
                {
                    t.variablesExpanded = false;
                }

                Rect plusRect = listRect;
                plusRect.x     += plusRect.width - plusWidth;
                plusRect.y     -= plusHeight - 1;
                plusRect.width  = plusWidth;
                plusRect.height = plusHeight;

                if (!Application.isPlaying &&
                    GUI.Button(plusRect, FungusEditorResources.texAddButton))
                {
                    GenericMenu        menu  = new GenericMenu();
                    List <System.Type> types = FindAllDerivedTypes <Variable>();

                    // Add variable types without a category
                    foreach (System.Type type in types)
                    {
                        VariableInfoAttribute variableInfo = VariableEditor.GetVariableInfo(type);
                        if (variableInfo == null ||
                            variableInfo.Category != "")
                        {
                            continue;
                        }

                        AddVariableInfo addVariableInfo = new AddVariableInfo();
                        addVariableInfo.fungusScript = t;
                        addVariableInfo.variableType = type;

                        GUIContent typeName = new GUIContent(variableInfo.VariableType);

                        menu.AddItem(typeName, false, AddVariable, addVariableInfo);
                    }

                    // Add types with a category
                    foreach (System.Type type in types)
                    {
                        VariableInfoAttribute variableInfo = VariableEditor.GetVariableInfo(type);
                        if (variableInfo == null ||
                            variableInfo.Category == "")
                        {
                            continue;
                        }

                        AddVariableInfo info = new AddVariableInfo();
                        info.fungusScript = t;
                        info.variableType = type;

                        GUIContent typeName = new GUIContent(variableInfo.Category + "/" + variableInfo.VariableType);

                        menu.AddItem(typeName, false, AddVariable, info);
                    }

                    menu.ShowAsContext();
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
예제 #7
0
 private void DrawGraphis()
 {
     ReorderableListGUI.Title("显示控件");
     ReorderableListGUI.ListField <Graphic>(graphics, GrapDrawer);
 }
예제 #8
0
 private void DrawGroupNode()
 {
     ReorderableListGUI.Title("信息列表");
     ReorderableListGUI.ListField(groupsProp);
 }
예제 #9
0
    protected override void DrawCustomProperties()
    {
        UIParticle particle = target as UIParticle;

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Reset Particles"))
        {
            if (EditorUtility.DisplayDialogComplex("重置控件", "重置控件会导致特效顺序重置!", "YES", "NO", "Cancel") == 0)
            {
                particle.RefreshParticles();
                serializedObject.ApplyModifiedProperties();
            }
        }
        if (GUILayout.Button("Play"))
        {
            if (Application.isPlaying)
            {
                particle.Play(1f);
            }
        }
        if (GUILayout.Button("Loop"))
        {
            if (Application.isPlaying)
            {
                particle.Play(-1f);
            }
        }
        GUILayout.EndHorizontal();

        if (particle.Particles == null || particle.Particles.Count == 0)
        {
            var style = new GUIStyle();
            style.normal.textColor = Color.red;
            style.hover.textColor  = Color.yellow;
            GUILayout.Label("No Particle exits in children!", style);
        }
        else
        {
            serializedObject.Update();
            ReorderableListGUI.Title("Particles");
            ReorderableListGUI.ListField(_particlesProperty, ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.HideAddButton | ReorderableListFlags.ShowIndices);
            serializedObject.FindProperty("extraRQ").intValue = _particlesProperty.arraySize > 0 ? _particlesProperty.arraySize - 1 : 0;
            serializedObject.ApplyModifiedProperties();
            //GUILayout.BeginHorizontal();
            NGUIEditorTools.DrawProperty("animator", serializedObject, "animator", GUILayout.MinWidth(20f));
            if (particle.animator != null)
            {
                NGUIEditorTools.DrawProperty("↘defaultClip", serializedObject, "defaultClip", GUILayout.MinWidth(20f));
            }
            //GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            NGUIEditorTools.DrawProperty("playOnAwake", serializedObject, "playOnAwake", GUILayout.MinWidth(20f));
            if (particle.playOnAwake)
            {
                NGUIEditorTools.DrawProperty("duration", serializedObject, "duration", GUILayout.MinWidth(20f));
            }
            GUILayout.EndHorizontal();

            EditorGUI.BeginDisabledGroup(true);
            GUILayout.BeginHorizontal();
            NGUIEditorTools.DrawProperty("extraRQ", serializedObject, "extraRQ", GUILayout.MinWidth(20f));
            NGUIEditorTools.DrawProperty("RQ", serializedObject, "renderQueue", GUILayout.MinWidth(20f));
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();
#if UNITY_EDITOR
            //if (lastRQ != particle.renderQueue || particle.Particles != particles)
            //{
            //    lastRQ = particle.renderQueue;
            //    particle.ResetRQ();
            //    EditorApplication.RepaintHierarchyWindow();
            //}
#endif
            base.DrawCustomProperties();
        }
        particles.Clear();
        particles.AddRange(particle.Particles);
    }
예제 #10
0
        private void DrawListField(
            string fieldName,
            Core.PropertyInfoType type,
            Type @enum,
            Type ptrType,
            IList list,
            Entity entity,
            bool isResizable)
        {
            ReorderableListGUI.Title(fieldName);

            ReorderableListFlags flags = ReorderableListFlags.ShowIndices;

            if (!isResizable)
            {
                flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.ShowIndices;
            }

            switch (type)
            {
            case Core.PropertyInfoType.Int8:
                ReorderableListGUI.ListField(
                    list as IList <sbyte>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.UInt8:
                ReorderableListGUI.ListField(
                    list as IList <byte>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.Int16:
                ReorderableListGUI.ListField(
                    list as IList <short>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.UInt16:
                ReorderableListGUI.ListField(
                    list as IList <ushort>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.Int32:
                if (@enum != null)
                {
                    // I'm sorry
                    // I'll fix this later I swear
                    var castList = new List <int>(list.Count);
                    castList.AddRange(from object item in list select Convert.ToInt32(item));

                    ReorderableListGUI.ListField(
                        castList,
                        (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                        DrawEmpty,
                        flags);

                    list.Clear();
                    foreach (var item in castList)
                    {
                        list.Add(Enum.ToObject(@enum, item));
                    }
                    break;
                }

                ReorderableListGUI.ListField(
                    list as IList <int>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.UInt32:
                ReorderableListGUI.ListField(
                    list as IList <uint>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.Int64:
                ReorderableListGUI.ListField(
                    list as IList <long>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.UInt64:
                ReorderableListGUI.ListField(
                    list as IList <ulong>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.Float:
                ReorderableListGUI.ListField(
                    list as IList <float>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.Double:
                ReorderableListGUI.ListField(
                    list as IList <double>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.Bool:
                ReorderableListGUI.ListField(
                    list as IList <bool>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.String:
                ReorderableListGUI.ListField(
                    list as IList <string>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.Path:
                ReorderableListGUI.ListField(
                    list as IList <UnityEngine.Object>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.EntityPtr:
                var genericAdapterType = typeof(EntityPtrListAdapter <>).MakeGenericType(ptrType);
                var adapter            = Activator.CreateInstance(genericAdapterType, list, ptrType, entity) as IReorderableListAdaptor;
                ReorderableListGUI.ListField(adapter);
                break;

            case Core.PropertyInfoType.Vector3:
                ReorderableListGUI.ListField(
                    list as IList <UnityEngine.Vector3>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.Vector4:
                ReorderableListGUI.ListField(
                    list as IList <UnityEngine.Vector4>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.Quat:
                ReorderableListGUI.ListField(
                    list as IList <UnityEngine.Quaternion>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.Matrix3:
                break;

            case Core.PropertyInfoType.Matrix4:
                ReorderableListGUI.ListField(
                    list as IList <UnityEngine.Matrix4x4>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.Color:
                ReorderableListGUI.ListField(
                    list as IList <Color>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.FilePtr:
                ReorderableListGUI.ListField(
                    list as IList <UnityEngine.Object>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.EntityHandle:
                ReorderableListGUI.ListField(
                    list as IList <Entity>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.EntityLink:
                ReorderableListGUI.ListField(
                    list as IList <EntityLink>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType),
                    DrawEmpty,
                    flags);
                break;

            case Core.PropertyInfoType.PropertyInfo:
                break;

            case Core.PropertyInfoType.WideVector3:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
예제 #11
0
        public virtual void DrawSequenceGUI(FungusScript fungusScript)
        {
            serializedObject.Update();

            Sequence sequence = target as Sequence;

            SerializedProperty descriptionProp = serializedObject.FindProperty("description");

            EditorGUILayout.PropertyField(descriptionProp);

            SerializedProperty runSlowInEditorProp = serializedObject.FindProperty("runSlowInEditor");

            EditorGUILayout.PropertyField(runSlowInEditorProp);

            DrawEventHandlerGUI(fungusScript);

            UpdateIndentLevels(sequence);

            SerializedProperty sequenceNameProperty = serializedObject.FindProperty("sequenceName");
            Rect sequenceLabelRect = new Rect(45, 5, 120, 16);

            EditorGUI.LabelField(sequenceLabelRect, new GUIContent("Sequence Name"));
            Rect sequenceNameRect = new Rect(45, 21, 180, 16);

            EditorGUI.PropertyField(sequenceNameRect, sequenceNameProperty, new GUIContent(""));

            // Ensure sequence name is unique for this Fungus Script
            string uniqueName = fungusScript.GetUniqueSequenceKey(sequenceNameProperty.stringValue, sequence);

            if (uniqueName != sequence.sequenceName)
            {
                sequenceNameProperty.stringValue = uniqueName;
            }

            // Make sure each command has a reference to its parent sequence
            foreach (Command command in sequence.commandList)
            {
                if (command == null)                 // Will be deleted from the list later on
                {
                    continue;
                }
                command.parentSequence = sequence;
            }

            SerializedProperty commandListProperty = serializedObject.FindProperty("commandList");

            ReorderableListGUI.Title("Commands");
            CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0);

            adaptor.nodeRect = sequence.nodeRect;

            ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu;

            ReorderableListControl.DrawControlFromState(adaptor, null, flags);

            if (Event.current.type == EventType.ContextClick)
            {
                ShowContextMenu();
            }

            if (sequence == fungusScript.selectedSequence)
            {
                // Show add command button
                {
                    GUILayout.BeginHorizontal();

                    // Up Button
                    Texture2D upIcon = Resources.Load("Icons/up") as Texture2D;
                    if (GUILayout.Button(upIcon))
                    {
                        SelectPrevious();
                    }
                    // Down Button
                    Texture2D downIcon = Resources.Load("Icons/down") as Texture2D;
                    if (GUILayout.Button(downIcon))
                    {
                        SelectNext();
                    }

                    GUILayout.FlexibleSpace();

                    // Add Button
                    Texture2D addIcon = Resources.Load("Icons/add") as Texture2D;
                    if (GUILayout.Button(addIcon) || ((Event.current.type == EventType.KeyDown) && (Event.current.keyCode == KeyCode.A)))
                    {
                        ShowCommandMenu();
                    }

                    // Duplicate Button
                    Texture2D duplicateIcon = Resources.Load("Icons/duplicate") as Texture2D;
                    if (GUILayout.Button(duplicateIcon))
                    {
                        Copy();
                        Paste();
                    }

                    // Delete Button
                    Texture2D deleteIcon = Resources.Load("Icons/delete") as Texture2D;
                    if (GUILayout.Button(deleteIcon) || ((Event.current.type == EventType.KeyDown) && (Event.current.keyCode == KeyCode.Delete)))
                    {
                        Delete();
                    }

                    GUILayout.EndHorizontal();
                }
            }

            // Remove any null entries in the command list.
            // This can happen when a command class is deleted or renamed.
            for (int i = commandListProperty.arraySize - 1; i >= 0; --i)
            {
                SerializedProperty commandProperty = commandListProperty.GetArrayElementAtIndex(i);
                if (commandProperty.objectReferenceValue == null)
                {
                    commandListProperty.DeleteArrayElementAtIndex(i);
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
예제 #12
0
        private static void DrawStringMapField(
            string fieldName,
            Core.PropertyInfoType type,
            Type @enum,
            Type ptrType,
            IDictionary dictionary,
            Entity entity)
        {
            ReorderableListGUI.Title(fieldName);

            switch (type)
            {
            case Core.PropertyInfoType.Int8:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, sbyte>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.UInt8:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, byte>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.Int16:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, short>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.UInt16:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, ushort>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.Int32:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, int>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.UInt32:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, uint>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.Int64:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, long>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.UInt64:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, ulong>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.Float:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, float>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.Double:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, double>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.Bool:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, bool>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.String:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, string>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.Path:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, UnityEngine.Object>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.EntityPtr:
                // We don't know the type at compile time so we need to do reflection BS to invoke the draw method.
                // Please God come up with a better way to do this.
                var adapterType = typeof(EntityPtrStringMapAdapter <>).MakeGenericType(ptrType);
                var adapter     = Activator.CreateInstance(adapterType, dictionary, ptrType, entity);

                var delegateType        = typeof(StringMapGUI.ItemDrawerWithKey <>).MakeGenericType(ptrType);
                var adapterDrawFunc     = adapterType.GetMethod("DrawEntityPtrItem");
                var adapterDrawDelegate = Delegate.CreateDelegate(delegateType, adapter, adapterDrawFunc);

                var renderFunc = typeof(StringMapGUI).GetMethod(nameof(StringMapGUI.StringMapFieldWithKey)).MakeGenericMethod(ptrType);
                renderFunc.Invoke(null, new object[] { dictionary, adapterDrawDelegate });

                break;

            case Core.PropertyInfoType.Vector3:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, UnityEngine.Vector3>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.Vector4:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, UnityEngine.Vector4>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.Quat:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, UnityEngine.Quaternion>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.Matrix3:
                break;

            case Core.PropertyInfoType.Matrix4:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, UnityEngine.Matrix4x4>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.Color:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, UnityEngine.Color>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.FilePtr:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, UnityEngine.Object>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.EntityHandle:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, Entity>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.EntityLink:
                StringMapGUI.StringMapField(
                    dictionary as IDictionary <string, EntityLink>,
                    (position, itemValue) => DrawListItem(position, itemValue, type, @enum, ptrType));
                break;

            case Core.PropertyInfoType.PropertyInfo:
                break;

            case Core.PropertyInfoType.WideVector3:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
예제 #13
0
    public override void OnInspectorGUI()
    {
        bool       reconstruct = false;
        LevelAsset myTarget    = (LevelAsset)target;

        var editorModeCached = editorMode;

        string[] editorModeOptions = { "Select", "Add" };
        editorMode = (EditorMode)EditorGUILayout.Popup("Mode", (int)editorMode, editorModeOptions);

        if (editorModeCached != editorMode)
        {
            reconstruct = true;
        }

        if (editorMode == EditorMode.Add)
        {
            string[] pieceOptions = Enum.GetNames(typeof(PieceType));
            pieceType = (PieceType)EditorGUILayout.Popup("Piece Type", (int)pieceType, pieceOptions);
        }

        if (cameraGameObject != null)
        {
            EditorGUI.DrawPreviewTexture(new Rect(0 + windowOffset.x, 0 + windowOffset.y, windowSize.x, windowSize.y), editorRenderTexture);
        }

        var tmpMousePos = Event.current.mousePosition;

        tmpMousePos -= windowOffset;
        tmpMousePos -= windowSize * 0.5f;
        var mousePosInGrid = new Vector3(Mathf.RoundToInt(tmpMousePos.x / windowGridSize), 0, -Mathf.RoundToInt(tmpMousePos.y / windowGridSize));

        if (Event.current.type == EventType.MouseDown && IsPositionWithinWindow(Event.current.mousePosition))
        {
            if (editorMode == EditorMode.Select)
            {
                selectPos      = mousePosInGrid;
                selectableTile = myTarget.Tiles.Find(x => { return(x.Pos == mousePosInGrid); });

                reconstruct = true;
            }
            else if (editorMode == EditorMode.Add)
            {
                if (pieceType == PieceType.Tile)
                {
                    if (Event.current.button == 0)
                    {
                        if (!myTarget.Tiles.Exists(x => { return(x.Pos == mousePosInGrid); }))
                        {
                            myTarget.Tiles.Add(new TileData(mousePosInGrid));
                            reconstruct = true;
                        }
                    }

                    if (Event.current.button == 1)
                    {
                        var posibleTile = myTarget.Tiles.Find(x => { return(x.Pos == mousePosInGrid); });
                        if (posibleTile != null)
                        {
                            myTarget.Tiles.Remove(posibleTile);
                            reconstruct = true;
                        }
                    }
                }
                else
                {
                    var posibleTile = myTarget.Tiles.Find(x => { return(x.Pos == mousePosInGrid); });
                    if (Event.current.button == 0)
                    {
                        if (posibleTile != null && posibleTile.Pieces.Count == 0)
                        {
                            posibleTile.Pieces.Add(new PieceData(pieceType));
                            reconstruct = true;
                        }
                    }
                    if (Event.current.button == 1)
                    {
                        if (posibleTile != null && posibleTile.Pieces.Count != 0)
                        {
                            posibleTile.Pieces = new List <PieceData>();
                            reconstruct        = true;
                        }
                    }
                }
            }
        }

        if (Event.current.button == 2)
        {
            if (Event.current.type == EventType.MouseDown)
            {
                mousePos = Event.current.mousePosition;
            }
            if (Event.current.type == EventType.MouseDrag)
            {
                var mouseDir = (mousePos - Event.current.mousePosition) * 0.01f;
                cameraGameObject.transform.position += new Vector3(mouseDir.x, 0, -mouseDir.y);
                mousePos = Event.current.mousePosition;
            }
        }

        if (reconstruct)
        {
            DestroyLevel();
            ConstructLevel();
        }

        if (editorMode == EditorMode.Select && selectableTile != null)
        {
            EditorGUILayout.BeginVertical();
            GUILayout.Space(windowOffset.y + windowSize.y);


            ReorderableListGUI.Title("Selection");
            ReorderableListGUI.ListField <PieceData>(selectableTile.Pieces, SelectionOfPieceDrawer);
            EditorGUILayout.EndVertical();
        }

        EditorUtility.SetDirty(myTarget);
    }
예제 #14
0
        /// <summary>
        ///     Draw a field
        /// </summary>
        /// <param name="field">Field to draw</param>
        /// <param name="indent">Indent the display of the field</param>
        protected virtual void DrawField(FieldInfo field, int indent = 0)
        {
            bool overrideParentValue = datablock.DoesOverridesParent(field) || datablock.Parent == null;

            Type   fieldType = field.FieldType;
            object val       = null;

            bool isDatablockReference = false;

            if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(DatablockRef <>))
            {
                fieldType            = fieldType.GetGenericArguments()[0];
                val                  = datablock.GetFieldValue <IDatablockRef>(field).GetObject();
                isDatablockReference = true;
            }
            else
            {
                val = datablock.GetFieldValue(field);
            }

            // Set the indent
            EditorGUI.indentLevel = indent;

            // Field overrides parent, or doesn't have a parent
            if (fieldType == typeof(int))
            {
                EditorGUILayout.BeginHorizontal();

                //var val = (int) field.GetValue(datablock);
                int newVal = EditorGUILayout.IntField(FieldLabel(field), (int)val);

                if ((int)val != newVal)
                {
                    SetFieldValue(field, newVal);
                }
            }
            else if (fieldType == typeof(float))
            {
                EditorGUILayout.BeginHorizontal();

                float newVal = EditorGUILayout.FloatField(FieldLabel(field), (float)val);

                if ((float)val != newVal)
                {
                    SetFieldValue(field, newVal);
                }
            }
#if UNITY_5_0
            else if (fieldType == typeof(double))
            {
                EditorGUILayout.BeginHorizontal();

                double newVal = EditorGUILayout.DoubleField(FieldLabel(field), (double)val);

                if ((double)val != newVal)
                {
                    SetFieldValue(field, newVal);
                }
            }
#endif
            else if (fieldType == typeof(bool))
            {
                EditorGUILayout.BeginHorizontal();

                bool newVal = EditorGUILayout.Toggle(FieldLabel(field), (bool)val);

                if ((bool)val != newVal)
                {
                    SetFieldValue(field, newVal);
                }
            }
            else if (fieldType == typeof(Vector2))
            {
                EditorGUILayout.BeginHorizontal();

                Vector2 newVal = EditorGUILayout.Vector2Field(FieldLabel(field), (Vector2)val);

                if ((Vector2)val != newVal)
                {
                    SetFieldValue(field, newVal);
                }
            }
            else if (fieldType == typeof(Vector3))
            {
                EditorGUILayout.BeginHorizontal();

                Vector3 newVal = EditorGUILayout.Vector3Field(FieldLabel(field), (Vector3)val);

                if ((Vector3)val != newVal)
                {
                    SetFieldValue(field, newVal);
                }
            }
            else if (fieldType == typeof(Vector4))
            {
                EditorGUILayout.BeginHorizontal();

                Vector4 newVal = EditorGUILayout.Vector4Field(FormatName(field.Name), (Vector4)val);

                if ((Vector4)val != newVal)
                {
                    SetFieldValue(field, newVal);
                }
            }
            else if (fieldType == typeof(Color))
            {
                EditorGUILayout.BeginHorizontal();

                Color newVal = EditorGUILayout.ColorField(FieldLabel(field), (Color)val);

                if ((Color)val != newVal)
                {
                    SetFieldValue(field, newVal);
                }
            }
            else if (fieldType.IsSubclassOf(typeof(Object)))
            {
                EditorGUILayout.BeginHorizontal();

                Object newVal = EditorGUILayout.ObjectField(FieldLabel(field), (Object)val, fieldType, false);
                if ((Object)val != newVal)
                {
                    if (isDatablockReference)
                    {
                        object val2 = Activator.CreateInstance(field.FieldType, new object[] { newVal });
                        SetFieldValue(field, val2);
                    }
                    else
                    {
                        SetFieldValue(field, newVal);
                    }
                }
            }
            else if (fieldType == typeof(string))
            {
                EditorGUILayout.BeginHorizontal();

                string newVal = EditorGUILayout.TextField(FieldLabel(field), (string)val);

                if ((string)val != newVal)
                {
                    SetFieldValue(field, newVal);
                }
            }
            else if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(List <>))
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.BeginVertical();

                serializedObject.Update();
                SerializedProperty listProperty = serializedObject.FindProperty(field.Name);

                try
                {
                    ReorderableListGUI.Title(field.Name);
                    ReorderableListGUI.ListField(listProperty);
                }
                catch (ExitGUIException)
                {
                    // suppress unity bug
                }

                serializedObject.ApplyModifiedProperties();
                EditorGUILayout.EndVertical();
            }
            else if (fieldType.IsEnum)
            {
                EditorGUILayout.BeginHorizontal();

                Enum newVal;

                if (Attribute.IsDefined(fieldType, typeof(FlagsAttribute)))
                {
                    newVal = EditorGUILayout.EnumMaskField(FieldLabel(field), (Enum)val);
                }
                else
                {
                    newVal = EditorGUILayout.EnumPopup(FieldLabel(field), (Enum)val);
                }

                if (!Equals((Enum)val, newVal))
                {
                    SetFieldValue(field, newVal);
                }
            }
            else
            {
                return;
            }

            EditorGUI.indentLevel = 0;
            EditorGUI.BeginDisabledGroup(datablock.Parent == null);
            {
                bool useParentValPrev = overrideParentValue;
                overrideParentValue = EditorGUILayout.Toggle("", overrideParentValue, GUILayout.MaxWidth(20));
                if (overrideParentValue != useParentValPrev)
                {
                    datablock.SetOverridesParent(field, overrideParentValue);

                    if (overrideParentValue)
                    {
                        field.SetValue(datablock, GetDefaultValue(fieldType));
                    }
                }
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();

            if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(List <>))
            {
                EditorGUILayout.Space();
                EditorGUILayout.Space();
            }
        }
예제 #15
0
        void OnGUI_DoEnumDefinitionForm()
        {
            if (EditorApplication.isCompiling)
            {
                Color _prev = GUI.color;
                GUI.color = Color.green;
                GUILayout.Box("Unity is compiling, please wait");
                GUI.color = _prev;
            }

            GUI.enabled = !EditorApplication.isCompiling;


            Color _orig = Color.clear;

            ReBuildPreview = false;

            if (currentEnumFileDetails != null)
            {
                Color _prev = GUI.color;
                GUI.color = Color.yellow;
                GUILayout.Box("You are editing an existing enum");
                GUI.color = _prev;


                FsmEditorGUILayout.Divider();
            }

            // FOLDER
            _orig = GUI.color;
            if (!currentEnum.FolderPathValidation.success)
            {
                GUI.color = new Color(255, 165, 0);
            }
            GUILayout.Label("Project Folder: <color=#ffa500><b>" + currentEnum.FolderPathValidation.message + "</b></color>");
            currentEnum.FolderPath = GUILayout.TextField(currentEnum.FolderPath);
            GUI.color = _orig;

            // NAMESPACE
            _orig = GUI.color;
            if (!currentEnum.NameSpaceValidation.success)
            {
                GUI.color = Color.red;
            }
            GUILayout.Label("NameSpace: <color=#B20000><b>" + currentEnum.NameSpaceValidation.message + "</b></color>");
            string _nameSpace = GUILayout.TextField(currentEnum.NameSpace);

            GUI.color = _orig;
            if (!string.Equals(_nameSpace, currentEnum.NameSpace))
            {
                currentEnum.NameSpace = _nameSpace;
                ReBuildPreview        = true;
            }

            // NAME
            _orig = GUI.color;
            if (!currentEnum.NameValidation.success)
            {
                GUI.color = Color.red;
            }
            GUILayout.Label("Enum Name: <color=#B20000><b>" + currentEnum.NameValidation.message + "</b></color>");
            string _name = GUILayout.TextField(currentEnum.Name);

            GUI.color = _orig;
            if (!string.Equals(_name, currentEnum.Name))
            {
                currentEnum.Name = _name;
                ReBuildPreview   = true;
            }

            // ENTRIES

            enumEntriesScrollPos = GUILayout.BeginScrollView(enumEntriesScrollPos);
            int count = currentEnum.entries.Count;



            List <string> _origEntries = new List <string>(currentEnum.entries);

            ReorderableListGUI.Title("Enum Entries:  <color=#B20000><b>" + currentEnum.EntriesValidation.message + "</b></color>");


            if (!allowReordering)
            {
                ReorderableListGUI.ListField(currentEnum.entries, DrawListItem, ReorderableListFlags.DisableReordering);
            }
            else
            {
                ReorderableListGUI.ListField(currentEnum.entries, DrawListItem);
            }
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            allowReordering = GUILayout.Toggle(allowReordering, "Enable Reordering");
            GUILayout.EndHorizontal();

            if (allowReordering && currentEnumFileDetails != null)
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label("Reordering values can break existing reference");
                GUILayout.EndHorizontal();
            }


            if (currentEnum.entries.Count != count || _origEntries != currentEnum.entries)
            {
                ReBuildPreview = true;
            }

            GUILayout.EndScrollView();

            FsmEditorGUILayout.Divider();


            //if (Event.current.type != EventType.Layout)
            //{
            if (!currentEnum.DefinitionValidation.success)
            {
                GUILayout.Label("<color=#B20000><b>" + currentEnum.DefinitionValidation.message + "</b></color>");
            }
            //}
            GUILayout.BeginHorizontal();


            if (GUILayout.Button("Start New"))
            {
                StartEditingNewEnum();
                currentEnum.Name = "";                 // force the user to pick a name
            }

            if (currentEnumFileDetails != null)
            {
                if (GUILayout.Button("Revert"))
                {
                    StartEditingExistingEnum(_sourceDetails);
                }
            }


            if (currentEnum.DefinitionValidation.success)
            {
                //	MatchFormWithExistingEnum();

                if (GUILayout.Button("Save"))                 // Label "Save Changes" when we detected that we are editing an existing enum
                {
                    enumCreator.CreateEnum(currentEnum);
                }
            }
            else
            {
                Color _color = GUI.color;

                _color.a  = 0.5f;
                GUI.color = _color;
                GUILayout.Label("Save", "Button");
                _color.a  = 1f;
                GUI.color = _color;
            }

            GUILayout.EndHorizontal();


            FsmEditorGUILayout.Divider();

            GUILayout.FlexibleSpace();

            bool newSourcePreviewFoldout = EditorGUILayout.Foldout(sourcePreviewFoldout, "Code Source Preview:");

            if (newSourcePreviewFoldout != sourcePreviewFoldout)
            {
                sourcePreviewFoldout = newSourcePreviewFoldout;
                EditorPrefs.SetBool(__CodeSourceFoldOutPrefKey__, sourcePreviewFoldout);
            }

            if (sourcePreviewFoldout)
            {
                sourcePreviewScrollPos = GUILayout.BeginScrollView(sourcePreviewScrollPos);
                GUILayout.TextArea(currentEnum.EnumLiteralPreview);
                GUILayout.EndScrollView();
            }

            /*
             * if ( ReBuildPreview || string.IsNullOrEmpty(currentEnum.ScriptLiteral) )
             * {
             *      currentEnum.ValidateDefinition();
             *
             *      enumCreator.BuildScriptLiteral(currentEnum);
             *      Repaint();
             * }
             */
        }
예제 #16
0
        public void OnGUI()
        {
            var settins = UM_GoogleAdsSettings.Instance;

            using (new SA_GuiBeginHorizontal())
            {
                GUILayout.FlexibleSpace();
                var example = GUILayout.Button("Example", EditorStyles.miniButton, GUILayout.Width(80));
                if (example)
                {
                    FillExampleSettings();
                }

                var click = GUILayout.Button("Dashboard", EditorStyles.miniButton, GUILayout.Width(80));
                if (click)
                {
                    Application.OpenURL("https://apps.admob.com/");
                }
            }

            using (new SA_H2WindowBlockWithSpace(new GUIContent("IOS")))
            {
                UM_AdvertisementUI.DrawPlatformIds(settins.IOSIds);
            }

            using (new SA_H2WindowBlockWithSpace(new GUIContent("ANDROID")))
            {
                if (string.IsNullOrEmpty(settins.AndroidIds.AppId))
                {
                    EditorGUILayout.HelpBox("Application id MUST be provided on Android platform before you make a build. " +
                                            "Empty Application id may result in app crash on launch.", MessageType.Error);
                }

                UM_AdvertisementUI.DrawPlatformIds(settins.AndroidIds);
            }

            using (new SA_H2WindowBlockWithSpace(new GUIContent("SETTINGS")))
            {
#if SA_ADMOB_INSTALLED
                settins.BannerSize     = (UM_GoogleBannerSize)SA_EditorGUILayout.EnumPopup("Banner Size", settins.BannerSize);
                settins.BannerPosition = (AdPosition)SA_EditorGUILayout.EnumPopup("Banner Position", settins.BannerPosition);
#endif

                settins.NPA = SA_EditorGUILayout.ToggleFiled("Non-Personalized Ads",
                                                             settins.TagForChildDirectedTreatment,
                                                             SA_StyledToggle.ToggleType.YesNo);

                settins.TagForChildDirectedTreatment = SA_EditorGUILayout.ToggleFiled("Tag For Child Directed Treatment",
                                                                                      settins.TagForChildDirectedTreatment,
                                                                                      SA_StyledToggle.ToggleType.YesNo);

                ReorderableListGUI.Title("Test Devices");
                ReorderableListGUI.ListField(settins.TestDevices, DrawTextFiled, () => {
                    EditorGUILayout.LabelField("Configure your device as a test device.");
                });
                EditorGUILayout.Space();


                ReorderableListGUI.Title("Keywords");
                ReorderableListGUI.ListField(settins.Keywords, DrawTextFiled, () => {
                    EditorGUILayout.LabelField("Provide keywords to admob so the ads can be targeted.");
                });
                EditorGUILayout.Space();
            }

            if (GUI.changed)
            {
                UM_GoogleAdsSettings.Save();
            }
        }
예제 #17
0
        public virtual void DrawVariablesGUI()
        {
            serializedObject.Update();

            Flowchart t = target as Flowchart;

            if (t.variables.Count == 0)
            {
                t.variablesExpanded = true;
            }

            if (!t.variablesExpanded)
            {
                if (GUILayout.Button("Variables (" + t.variables.Count + ")", GUILayout.Height(24)))
                {
                    t.variablesExpanded = true;
                }

                // Draw disclosure triangle
                Rect lastRect = GUILayoutUtility.GetLastRect();
                lastRect.x += 5;
                lastRect.y += 5;
                EditorGUI.Foldout(lastRect, false, "");
            }
            else
            {
                Rect listRect = new Rect();

                if (t.variables.Count > 0)
                {
                    // Remove any null variables from the list
                    // Can sometimes happen when upgrading to a new version of Fungus (if .meta GUID changes for a variable class)
                    for (int i = t.variables.Count - 1; i >= 0; i--)
                    {
                        if (t.variables[i] == null)
                        {
                            t.variables.RemoveAt(i);
                        }
                    }

                    ReorderableListGUI.Title("Variables");
                    VariableListAdaptor adaptor = new VariableListAdaptor(variablesProp, 0);

                    ReorderableListFlags flags = ReorderableListFlags.DisableContextMenu | ReorderableListFlags.HideAddButton;

                    ReorderableListControl.DrawControlFromState(adaptor, null, flags);
                    listRect = GUILayoutUtility.GetLastRect();
                }
                else
                {
                    GUILayoutUtility.GetRect(300, 24);
                    listRect    = GUILayoutUtility.GetLastRect();
                    listRect.y += 20;
                }

                float plusWidth  = 32;
                float plusHeight = 24;

                Rect  buttonRect   = listRect;
                float buttonHeight = 24;
                buttonRect.x      = 4;
                buttonRect.y     -= buttonHeight - 1;
                buttonRect.height = buttonHeight;
                if (!Application.isPlaying)
                {
                    buttonRect.width -= 30;
                }

                if (GUI.Button(buttonRect, "Variables"))
                {
                    t.variablesExpanded = false;
                }

                // Draw disclosure triangle
                Rect lastRect = buttonRect;
                lastRect.x += 5;
                lastRect.y += 5;
                EditorGUI.Foldout(lastRect, true, "");

                Rect plusRect = listRect;
                plusRect.x     += plusRect.width - plusWidth;
                plusRect.y     -= plusHeight - 1;
                plusRect.width  = plusWidth;
                plusRect.height = plusHeight;

                if (!Application.isPlaying &&
                    GUI.Button(plusRect, addTexture))
                {
                    GenericMenu        menu  = new GenericMenu();
                    List <System.Type> types = FindAllDerivedTypes <Variable>();

                    // Add variable types without a category
                    foreach (System.Type type in types)
                    {
                        VariableInfoAttribute variableInfo = VariableEditor.GetVariableInfo(type);
                        if (variableInfo == null ||
                            variableInfo.Category != "")
                        {
                            continue;
                        }

                        AddVariableInfo addVariableInfo = new AddVariableInfo();
                        addVariableInfo.flowchart    = t;
                        addVariableInfo.variableType = type;

                        GUIContent typeName = new GUIContent(variableInfo.VariableType);

                        menu.AddItem(typeName, false, AddVariable, addVariableInfo);
                    }

                    // Add types with a category
                    foreach (System.Type type in types)
                    {
                        VariableInfoAttribute variableInfo = VariableEditor.GetVariableInfo(type);
                        if (variableInfo == null ||
                            variableInfo.Category == "")
                        {
                            continue;
                        }

                        AddVariableInfo info = new AddVariableInfo();
                        info.flowchart    = t;
                        info.variableType = type;

                        GUIContent typeName = new GUIContent(variableInfo.Category + "/" + variableInfo.VariableType);

                        menu.AddItem(typeName, false, AddVariable, info);
                    }

                    menu.ShowAsContext();
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
예제 #18
0
        public void OnGUI(BuildProcess pProcess, BuildCollection pCollection)
        {
            if (pProcess == null)
            {
                return;
            }

            if (pProcess != mEditedBuildProcess)
            {
                if (mEditedBuildProcess != null)
                {
                    SaveScenesToStringList();
                }

                mEditedBuildProcess = pProcess;
                mCollection         = pCollection;

                LoadScenesFromStringList();
                OnEnable();

                // after switching to another process, we want to make sure to unfocus all possible controls
                // like textfields. This will remove an issue, where dangling focus between process switching could happen
                GUI.FocusControl("");
            }

            GUILayout.BeginVertical();

            GUILayout.Label("Build Process", Styles.detailsTitle);

            Styles.HorizontalSeparator();

            Undo.RecordObject(mCollection, "Edit Build Process Details");
            pProcess.mName = EditorGUILayout.TextField("Name", mEditedBuildProcess.mName);


            mEditedBuildProcess.mPlatform = (BuildTarget)EditorGUILayout.EnumPopup("Platform", mEditedBuildProcess.mPlatform);

            mEditedBuildProcess.mPretend = EditorGUILayout.Toggle(new GUIContent("Pretend Build", "Will not trigger a unity build, but run everything else. "), mEditedBuildProcess.mPretend);

            GUILayout.Space(5);
            mShowBuildOptions = EditorGUILayout.Foldout(mShowBuildOptions, "Build Options");
            GUILayout.BeginHorizontal();
            GUILayout.Space(25);

            if (mShowBuildOptions)
            {
                GUILayout.BeginVertical();

                foreach (var buildOption in mBuildOptions)
                {
                    bool selVal = (mEditedBuildProcess.mBuildOptions & buildOption) != 0;
                    {
                        bool resVal = EditorGUILayout.ToggleLeft(buildOption.ToString(), selVal);
                        if (resVal != selVal)
                        {
                            if (resVal)
                            {
                                mEditedBuildProcess.mBuildOptions = mEditedBuildProcess.mBuildOptions | buildOption;
                            }
                            else
                            {
                                mEditedBuildProcess.mBuildOptions = mEditedBuildProcess.mBuildOptions & ~buildOption;
                            }
                            UpdateSelectedOptions();
                        }
                    }
                }


                GUILayout.EndVertical();
            }
            else
            {
                GUILayout.Label(selectedOptionsString);
            }


            GUILayout.EndHorizontal();
            GUILayout.Space(5);

            DrawOutputPathSelector();

            ReorderableListGUI.Title("Included Scenes");
            ReorderableListGUI.ListField(mEditedBuildProcess.mSceneAssets, SceneDrawer);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Copy scenes from settings"))
            {
                CopyScenesFromSettings();
            }

            if (GUILayout.Button("Clear scenes"))
            {
                mEditedBuildProcess.mSceneAssets.Clear();
            }

            GUILayout.EndHorizontal();

            Styles.HorizontalSeparator();

            mDrawingBuildStepType = EBuildStepType.PreBuildStep;
            ReorderableListGUI.Title("Pre Build Steps");
            ReorderableListGUI.ListField(mEditedBuildProcess.mPreBuildSteps, StepDrawer);


            Styles.HorizontalSeparator();
            GUILayout.Label("Actual Unity Build", Styles.mediumHint);
            Styles.HorizontalSeparator();


            mDrawingBuildStepType = EBuildStepType.PostBuildStep;
            ReorderableListGUI.Title("Post Build Steps");
            ReorderableListGUI.ListField(mEditedBuildProcess.mPostBuildSteps, StepDrawer);


            GUILayout.EndVertical();
        }
예제 #19
0
 private void DrawSelectables()
 {
     ReorderableListGUI.Title("交互控件");
     ReorderableListGUI.ListField <Selectable>(selectables, SelectableDrawer);
 }
예제 #20
0
 private void DrawGameObjectsList()
 {
     ReorderableListGUI.Title("Game Objects");
     ReorderableListGUI.ListField(gameObjects);
 }
예제 #21
0
 protected override void DrawRuntimeItems()
 {
     ReorderableListGUI.Title("共用资源列表");
     ReorderableListGUI.ListField(groupObjsProp);
     base.DrawRuntimeItems();
 }
예제 #22
0
 protected override void DrawProperties()
 {
     ReorderableListGUI.Title("Save Point Keys");
     ReorderableListGUI.ListField(savePointKeysProp);
 }
예제 #23
0
 /// <summary>
 /// Draws the given array type using a reorderable list drawer
 /// </summary>
 /// <param name="property"></param>
 /// <param name="label"></param>
 protected void DrawReorderableList(SerializedProperty property, string label)
 {
     //reorderableLists[property].DoLayoutList();
     ReorderableListGUI.Title(label);
     ReorderableListGUI.ListField(property);
 }
예제 #24
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        bl_Gun script            = (bl_Gun)target;
        bool   allowSceneObjects = !EditorUtility.IsPersistent(script);

        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.LabelField("", "Gun Info", "box");
        script.typeOfGun = (bl_Gun.weaponType)EditorGUILayout.EnumPopup("Type of Gun ", script.typeOfGun);

        if (script.typeOfGun != bl_Gun.weaponType.Launcher)
        {
            script.typeOfBullet = (bl_Gun.BulletType)EditorGUILayout.EnumPopup("Type of Ammo ", script.typeOfBullet);
        }
        //
        script.GunID           = EditorGUILayout.IntField("Gun ID ", script.GunID);
        script.GunName         = EditorGUILayout.TextField("Gun Name", script.GunName);
        script.localPlayerName = EditorGUILayout.TextField("Player Name", script.localPlayerName);
        script.CrossHairScale  = EditorGUILayout.Slider("CrossHair Scale: ", script.CrossHairScale, 1, 30);
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("box");

        if (script.typeOfGun == bl_Gun.weaponType.Machinegun || script.typeOfGun == bl_Gun.weaponType.Pistol || script.typeOfGun == bl_Gun.weaponType.Sniper)
        {
            EditorGUILayout.LabelField("", "Gun Settings", "box");
            EditorGUILayout.BeginVertical("box");
            script.AimPosition   = EditorGUILayout.Vector3Field("Aim Position", script.AimPosition);
            script.useSmooth     = EditorGUILayout.Toggle("Use Smooth", script.useSmooth);
            script.AimSmooth     = EditorGUILayout.Slider("Aim Smooth", script.AimSmooth, 0.01f, 15f);
            script.AimSway       = EditorGUILayout.Slider("Aim Sway", script.AimSway, 0.0f, 10);
            script.AimSwayAmount = EditorGUILayout.Slider("Aim Sway Amount", script.AimSwayAmount, 0.0f, 0.1f);
            script.AimFog        = EditorGUILayout.Slider("Aim Fog", script.AimFog, 0.0f, 179);
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
            script.bullet      = EditorGUILayout.ObjectField("Bullet", script.bullet, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            script.shell       = EditorGUILayout.ObjectField("Shell", script.shell, typeof(UnityEngine.Rigidbody), allowSceneObjects) as UnityEngine.Rigidbody;
            script.muzzlePoint = EditorGUILayout.ObjectField("Fire Point", script.muzzlePoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
            script.mountPoint  = EditorGUILayout.ObjectField("Mount Point", script.mountPoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
            script.ejectPoint  = EditorGUILayout.ObjectField("Eject Point", script.ejectPoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
            EditorGUILayout.LabelField("", "Fire Effects", "box");
            script.muzzleFlash  = EditorGUILayout.ObjectField("Muzzle Flash", script.muzzleFlash, typeof(UnityEngine.Renderer), allowSceneObjects) as UnityEngine.Renderer;
            script.lightFlash   = EditorGUILayout.ObjectField("Fire Light", script.lightFlash, typeof(UnityEngine.Light), allowSceneObjects) as UnityEngine.Light;
            script.impactEffect = EditorGUILayout.ObjectField("Impact Effect", script.impactEffect, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            script.bulletHole   = EditorGUILayout.ObjectField("Bullet Hole", script.bulletHole, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            EditorGUILayout.LabelField("", "Gun properties", "box");
            script.fireRate       = EditorGUILayout.FloatField("Fire Rate", script.fireRate);
            script.damage         = EditorGUILayout.FloatField("Damage", script.damage);
            script.range          = EditorGUILayout.IntField("Range", script.range);
            script.bulletSpeed    = EditorGUILayout.FloatField("Bullet Speed", script.bulletSpeed);
            script.impactForce    = EditorGUILayout.IntSlider("Imapact Force", script.impactForce, 0, 30);
            script.maxPenetration = EditorGUILayout.IntSlider("Max Penetration", (int)script.maxPenetration, 1, 6);
            EditorGUILayout.Space();
            script.ShakeIntense   = EditorGUILayout.Slider("Shake Intense", script.ShakeIntense, 0.0f, 2.0f);
            script.ShakeSmooth    = EditorGUILayout.FloatField("Shake Smooth", script.ShakeSmooth);
            script.kickBackAmount = EditorGUILayout.FloatField("Recoil", script.kickBackAmount);
            EditorGUILayout.Space();
            script.AutoReload       = EditorGUILayout.Toggle("Auto Reload", script.AutoReload);
            script.reloadTime       = EditorGUILayout.FloatField("Reload Time", script.reloadTime);
            script.bulletsPerClip   = EditorGUILayout.IntField("Bullets Per Clips", script.bulletsPerClip);
            script.maxNumberOfClips = EditorGUILayout.IntField("Max Clips", script.maxNumberOfClips);
            script.numberOfClips    = EditorGUILayout.IntSlider("Clips", script.numberOfClips, 0, script.maxNumberOfClips);
            EditorGUILayout.Space();
            script.baseSpread           = EditorGUILayout.FloatField("Base Spread", script.baseSpread);
            script.maxSpread            = EditorGUILayout.FloatField("Max Spread", script.maxSpread);
            script.spreadPerSecond      = EditorGUILayout.FloatField("Spread Per Seconds", script.spreadPerSecond);
            script.decreaseSpreadPerSec = EditorGUILayout.FloatField("Decrease Spread Per Sec", script.decreaseSpreadPerSec);
            EditorGUILayout.LabelField("", "Audio", "box");
            EditorGUILayout.BeginVertical("box");
            script.FireSound = EditorGUILayout.ObjectField("Fire Sound", script.FireSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            if (script.typeOfGun == bl_Gun.weaponType.Sniper)
            {
                script.delayForSecondFireSound = EditorGUILayout.Slider("Delay Second Fire Sound", script.delayForSecondFireSound, 0.0f, 2.0f);
                script.DelaySource             = EditorGUILayout.ObjectField("Second Source", script.DelaySource, typeof(UnityEngine.AudioSource), allowSceneObjects) as UnityEngine.AudioSource;
            }
            script.TakeSound         = EditorGUILayout.ObjectField("Take Sound", script.TakeSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            script.SoundReloadByAnim = EditorGUILayout.Toggle("Sounds Reload By Animation", script.SoundReloadByAnim);
            if (!script.SoundReloadByAnim)
            {
                script.ReloadSound  = EditorGUILayout.ObjectField("Reload Begin", script.ReloadSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
                script.ReloadSound2 = EditorGUILayout.ObjectField("Reload Middle", script.ReloadSound2, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
                script.ReloadSound3 = EditorGUILayout.ObjectField("Reload End", script.ReloadSound3, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            }
            EditorGUILayout.EndVertical();
        }
        if (script.typeOfGun == bl_Gun.weaponType.Burst)
        {
            EditorGUILayout.LabelField("", "Gun Settings", "box");
            EditorGUILayout.BeginVertical("box");
            script.AimPosition   = EditorGUILayout.Vector3Field("Aim Position", script.AimPosition);
            script.useSmooth     = EditorGUILayout.Toggle("Use Smooth", script.useSmooth);
            script.AimSmooth     = EditorGUILayout.Slider("Aim Smooth", script.AimSmooth, 1.0f, 15f);
            script.AimSway       = EditorGUILayout.Slider("Aim Sway", script.AimSway, 0.0f, 10);
            script.AimSwayAmount = EditorGUILayout.Slider("Aim Sway Amount", script.AimSwayAmount, 0.0f, 0.1f);
            script.AimFog        = EditorGUILayout.Slider("Aim Fog", script.AimFog, 0.0f, 179);
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
            script.bullet      = EditorGUILayout.ObjectField("Bullet", script.bullet, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            script.shell       = EditorGUILayout.ObjectField("Shell", script.shell, typeof(UnityEngine.Rigidbody), allowSceneObjects) as UnityEngine.Rigidbody;
            script.muzzlePoint = EditorGUILayout.ObjectField("Fire Point", script.muzzlePoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
            script.mountPoint  = EditorGUILayout.ObjectField("Mount Point", script.mountPoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
            script.ejectPoint  = EditorGUILayout.ObjectField("Eject Point", script.ejectPoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
            EditorGUILayout.LabelField("", "Fire Effects", "box");
            script.muzzleFlash  = EditorGUILayout.ObjectField("Muzzle Flash", script.muzzleFlash, typeof(UnityEngine.Renderer), allowSceneObjects) as UnityEngine.Renderer;
            script.lightFlash   = EditorGUILayout.ObjectField("Fire Light", script.lightFlash, typeof(UnityEngine.Light), allowSceneObjects) as UnityEngine.Light;
            script.impactEffect = EditorGUILayout.ObjectField("Impact Effect", script.impactEffect, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            script.bulletHole   = EditorGUILayout.ObjectField("Bullet Hole", script.bulletHole, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            EditorGUILayout.LabelField("", "Gun properties", "box");
            script.fireRate        = EditorGUILayout.FloatField("Fire Rate", script.fireRate);
            script.roundsPerBurst  = EditorGUILayout.IntSlider("Rounds Per Burst", script.roundsPerBurst, 1, 10);
            script.lagBetweenShots = EditorGUILayout.Slider("Lag Between Shots", script.lagBetweenShots, 0.01f, 5.0f);
            script.damage          = EditorGUILayout.FloatField("Damage", script.damage);
            script.range           = EditorGUILayout.IntField("Range", script.range);
            script.bulletSpeed     = EditorGUILayout.FloatField("Bullet Speed", script.bulletSpeed);
            script.impactForce     = EditorGUILayout.IntField("Impact Force", script.impactForce);
            script.maxPenetration  = EditorGUILayout.IntSlider("Max Penetration", (int)script.maxPenetration, 1, 6);
            EditorGUILayout.Space();
            script.ShakeIntense   = EditorGUILayout.Slider("Shake Intense", script.ShakeIntense, 0.0f, 2.0f);
            script.ShakeSmooth    = EditorGUILayout.FloatField("Shake Smooth", script.ShakeSmooth);
            script.kickBackAmount = EditorGUILayout.FloatField("Kick Back Amount", script.kickBackAmount);
            EditorGUILayout.Space();
            script.AutoReload       = EditorGUILayout.Toggle("Auto Reload", script.AutoReload);
            script.reloadTime       = EditorGUILayout.FloatField("Reload Time", script.reloadTime);
            script.bulletsPerClip   = EditorGUILayout.IntField("Bullets Per Clips", script.bulletsPerClip);
            script.maxNumberOfClips = EditorGUILayout.IntField("Max Clips", script.maxNumberOfClips);
            script.numberOfClips    = EditorGUILayout.IntSlider("Clips", script.numberOfClips, 0, script.maxNumberOfClips);
            EditorGUILayout.Space();
            script.baseSpread           = EditorGUILayout.FloatField("Base Spread", script.baseSpread);
            script.maxSpread            = EditorGUILayout.FloatField("Max Spread", script.maxSpread);
            script.spreadPerSecond      = EditorGUILayout.FloatField("Spread Per Seconds", script.spreadPerSecond);
            script.decreaseSpreadPerSec = EditorGUILayout.FloatField("Decrease Spread Per Sec", script.decreaseSpreadPerSec);
            EditorGUILayout.LabelField("", "Audio", "box");
            EditorGUILayout.BeginVertical("box");
            script.FireSound         = EditorGUILayout.ObjectField("Fire Sound", script.FireSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            script.TakeSound         = EditorGUILayout.ObjectField("Take Sound", script.TakeSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            script.SoundReloadByAnim = EditorGUILayout.Toggle("Sounds Reload By Animation", script.SoundReloadByAnim);
            if (!script.SoundReloadByAnim)
            {
                script.ReloadSound  = EditorGUILayout.ObjectField("Reload Begin", script.ReloadSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
                script.ReloadSound2 = EditorGUILayout.ObjectField("Reload Middle", script.ReloadSound2, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
                script.ReloadSound3 = EditorGUILayout.ObjectField("Reload End", script.ReloadSound3, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            }
            EditorGUILayout.EndVertical();
        }
        if (script.typeOfGun == bl_Gun.weaponType.Shotgun)
        {
            EditorGUILayout.LabelField("", "ShotGun Settings", "box");
            EditorGUILayout.BeginVertical("box");
            script.AimPosition   = EditorGUILayout.Vector3Field("Aim Position", script.AimPosition);
            script.useSmooth     = EditorGUILayout.Toggle("Use Smooth", script.useSmooth);
            script.AimSmooth     = EditorGUILayout.Slider("Aim Smooth", script.AimSmooth, 1.0f, 15f);
            script.AimSway       = EditorGUILayout.Slider("Aim Sway", script.AimSway, 0.0f, 10);
            script.AimSwayAmount = EditorGUILayout.Slider("Aim Sway Amount", script.AimSwayAmount, 0.0f, 0.1f);
            script.AimFog        = EditorGUILayout.Slider("Aim Fog", script.AimFog, 0.0f, 179);
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
            script.bullet      = EditorGUILayout.ObjectField("Bullet", script.bullet, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            script.shell       = EditorGUILayout.ObjectField("Shell", script.shell, typeof(UnityEngine.Rigidbody), allowSceneObjects) as UnityEngine.Rigidbody;
            script.muzzlePoint = EditorGUILayout.ObjectField("Fire Point", script.muzzlePoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
            script.mountPoint  = EditorGUILayout.ObjectField("Mount Point", script.mountPoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
            script.ejectPoint  = EditorGUILayout.ObjectField("Eject Point", script.ejectPoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
            EditorGUILayout.LabelField("", "Fire Effects", "box");
            script.muzzleFlash  = EditorGUILayout.ObjectField("Muzzle Flash", script.muzzleFlash, typeof(UnityEngine.Renderer), allowSceneObjects) as UnityEngine.Renderer;
            script.lightFlash   = EditorGUILayout.ObjectField("Fire Light", script.lightFlash, typeof(UnityEngine.Light), allowSceneObjects) as UnityEngine.Light;
            script.impactEffect = EditorGUILayout.ObjectField("Impact Effect", script.impactEffect, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            script.bulletHole   = EditorGUILayout.ObjectField("Bullet Hole", script.bulletHole, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            EditorGUILayout.LabelField("", "Gun properties", "box");
            script.fireRate        = EditorGUILayout.FloatField("Fire Rate", script.fireRate);
            script.damage          = EditorGUILayout.FloatField("Damage", script.damage);
            script.pelletsPerShot  = EditorGUILayout.IntSlider("Bullets Per Shots", (int)script.pelletsPerShot, 1, 10);
            script.roundsPerTracer = EditorGUILayout.IntSlider("Rounds Per Tracer", (int)script.roundsPerTracer, 1, 5);
            script.range           = EditorGUILayout.IntField("Range", script.range);
            script.bulletSpeed     = EditorGUILayout.FloatField("Bullet Speed", script.bulletSpeed);
            script.impactForce     = EditorGUILayout.IntField("Impact Force", script.impactForce);
            script.maxPenetration  = EditorGUILayout.IntSlider("Max Penetration", (int)script.maxPenetration, 1, 6);
            EditorGUILayout.Space();
            script.ShakeIntense   = EditorGUILayout.Slider("Shake Intense", script.ShakeIntense, 0.0f, 2.0f);
            script.ShakeSmooth    = EditorGUILayout.FloatField("Shake Smooth", script.ShakeSmooth);
            script.kickBackAmount = EditorGUILayout.FloatField("Kick Back Amount", script.kickBackAmount);
            EditorGUILayout.Space();
            script.AutoReload       = EditorGUILayout.Toggle("Auto Reload", script.AutoReload);
            script.reloadTime       = EditorGUILayout.FloatField("Reload Time", script.reloadTime);
            script.bulletsPerClip   = EditorGUILayout.IntField("Bullets Per Clips", script.bulletsPerClip);
            script.maxNumberOfClips = EditorGUILayout.IntField("Max Clips", script.maxNumberOfClips);
            script.numberOfClips    = EditorGUILayout.IntSlider("Clips", script.numberOfClips, 0, script.maxNumberOfClips);
            EditorGUILayout.Space();
            script.baseSpread           = EditorGUILayout.FloatField("Base Spread", script.baseSpread);
            script.maxSpread            = EditorGUILayout.FloatField("Max Spread", script.maxSpread);
            script.spreadPerSecond      = EditorGUILayout.FloatField("Spread Per Seconds", script.spreadPerSecond);
            script.decreaseSpreadPerSec = EditorGUILayout.FloatField("Decrease Spread Per Sec", script.decreaseSpreadPerSec);
            EditorGUILayout.LabelField("", "Audio", "box");
            EditorGUILayout.BeginVertical("box");
            script.FireSound = EditorGUILayout.ObjectField("Fire Sound", script.FireSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            script.delayForSecondFireSound = EditorGUILayout.Slider("Delay Second Fire Sound", script.delayForSecondFireSound, 0.0f, 2.0f);
            script.DelaySource             = EditorGUILayout.ObjectField("Second Source", script.DelaySource, typeof(UnityEngine.AudioSource), allowSceneObjects) as UnityEngine.AudioSource;
            script.TakeSound         = EditorGUILayout.ObjectField("Take Sound", script.TakeSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            script.SoundReloadByAnim = EditorGUILayout.Toggle("Sounds Reload By Animation", script.SoundReloadByAnim);
            if (!script.SoundReloadByAnim)
            {
                script.ReloadSound  = EditorGUILayout.ObjectField("Reload Begin", script.ReloadSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
                script.ReloadSound2 = EditorGUILayout.ObjectField("Reload Middle", script.ReloadSound2, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
                script.ReloadSound3 = EditorGUILayout.ObjectField("Reload End", script.ReloadSound3, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            }
            EditorGUILayout.EndVertical();
        }
        if (script.typeOfGun == bl_Gun.weaponType.Knife)
        {
            EditorGUILayout.LabelField("", "Knife Settings", "box");
            EditorGUILayout.BeginVertical("box");
            script.AimPosition   = EditorGUILayout.Vector3Field("Aim Position", script.AimPosition);
            script.useSmooth     = EditorGUILayout.Toggle("Use Smooth", script.useSmooth);
            script.AimSmooth     = EditorGUILayout.Slider("Aim Smooth", script.AimSmooth, 0.01f, 15f);
            script.AimSway       = EditorGUILayout.Slider("Aim Sway", script.AimSway, 0.0f, 10);
            script.AimSwayAmount = EditorGUILayout.Slider("Aim Sway Amount", script.AimSwayAmount, 0.0f, 0.1f);
            script.AimFog        = EditorGUILayout.Slider("Aim Fog", script.AimFog, 0.0f, 179);
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
            script.bullet = EditorGUILayout.ObjectField("Bullet", script.bullet, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            EditorGUILayout.LabelField("", "Fire Effects", "box");
            script.impactEffect = EditorGUILayout.ObjectField("Impact Effect", script.impactEffect, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            script.bulletHole   = EditorGUILayout.ObjectField("Bullet Hole", script.bulletHole, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            EditorGUILayout.LabelField("", "Gun properties", "box");
            script.fireRate       = EditorGUILayout.FloatField("Fire Rate", script.fireRate);
            script.damage         = EditorGUILayout.FloatField("Damage", script.damage);
            script.range          = EditorGUILayout.IntSlider("Range", script.range, 0, 25);
            script.bulletSpeed    = EditorGUILayout.FloatField("Bullet Speed", script.bulletSpeed);
            script.impactForce    = EditorGUILayout.IntSlider("Imapact Force", script.impactForce, 0, 30);
            script.maxPenetration = EditorGUILayout.IntSlider("Max Penetration", (int)script.maxPenetration, 1, 6);
            EditorGUILayout.Space();
            script.ShakeIntense   = EditorGUILayout.Slider("Shake Intense", script.ShakeIntense, 0.0f, 2.0f);
            script.ShakeSmooth    = EditorGUILayout.FloatField("Shake Smooth", script.ShakeSmooth);
            script.kickBackAmount = EditorGUILayout.FloatField("Kick Back Amount", script.kickBackAmount);
            EditorGUILayout.LabelField("", "Audio", "box");
            EditorGUILayout.BeginVertical("box");
            script.FireSound = EditorGUILayout.ObjectField("Fire Sound", script.FireSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            script.TakeSound = EditorGUILayout.ObjectField("Take Sound", script.TakeSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;

            EditorGUILayout.EndVertical();
        }
        if (script.typeOfGun == bl_Gun.weaponType.Launcher)
        {
            EditorGUILayout.LabelField("", "Launcher Settings", "box");
            EditorGUILayout.BeginVertical("box");
            script.AimPosition   = EditorGUILayout.Vector3Field("Aim Position", script.AimPosition);
            script.useSmooth     = EditorGUILayout.Toggle("Use Smooth", script.useSmooth);
            script.AimSmooth     = EditorGUILayout.Slider("Aim Smooth", script.AimSmooth, 1.0f, 15f);
            script.AimSway       = EditorGUILayout.Slider("Aim Sway", script.AimSway, 0.0f, 10);
            script.AimSwayAmount = EditorGUILayout.Slider("Aim Sway Amount", script.AimSwayAmount, 0.0f, 0.1f);
            script.AimFog        = EditorGUILayout.Slider("Aim Fog", script.AimFog, 0.0f, 179);
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
            script.grenade     = EditorGUILayout.ObjectField("Grenade", script.grenade, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
            script.muzzlePoint = EditorGUILayout.ObjectField("Fire Point", script.muzzlePoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
            EditorGUILayout.LabelField("", "Launcher properties", "box");
            script.fireRate       = EditorGUILayout.FloatField("Fire Rate", script.fireRate);
            script.DelayFire      = EditorGUILayout.FloatField("Delay Fire", script.DelayFire);
            script.damage         = EditorGUILayout.FloatField("Damage", script.damage);
            script.range          = EditorGUILayout.IntField("Range", script.range);
            script.bulletSpeed    = EditorGUILayout.FloatField("Projectil Speed", script.bulletSpeed);
            script.impactForce    = EditorGUILayout.IntField("Impact Force", script.impactForce);
            script.maxPenetration = EditorGUILayout.IntSlider("Max Penetration", (int)script.maxPenetration, 1, 6);
            EditorGUILayout.Space();
            script.ShakeIntense   = EditorGUILayout.Slider("Shake Intense", script.ShakeIntense, 0.0f, 2.0f);
            script.ShakeSmooth    = EditorGUILayout.FloatField("Shake Smooth", script.ShakeSmooth);
            script.kickBackAmount = EditorGUILayout.FloatField("Kick Back Amount", script.kickBackAmount);
            EditorGUILayout.Space();
            script.AutoReload       = EditorGUILayout.Toggle("Auto Reload", script.AutoReload);
            script.reloadTime       = EditorGUILayout.FloatField("Reload Time", script.reloadTime);
            script.bulletsPerClip   = EditorGUILayout.IntField("Bullets Per Clips", script.bulletsPerClip);
            script.maxNumberOfClips = EditorGUILayout.IntField("Max Clips", script.maxNumberOfClips);
            script.numberOfClips    = EditorGUILayout.IntSlider("Clips", script.numberOfClips, 0, script.maxNumberOfClips);
            EditorGUILayout.Space();
            script.baseSpread           = EditorGUILayout.FloatField("Base Spread", script.baseSpread);
            script.maxSpread            = EditorGUILayout.FloatField("Max Spread", script.maxSpread);
            script.spreadPerSecond      = EditorGUILayout.FloatField("Spread Per Seconds", script.spreadPerSecond);
            script.decreaseSpreadPerSec = EditorGUILayout.FloatField("Decrease Spread Per Sec", script.decreaseSpreadPerSec);
            EditorGUILayout.Space();

            ReorderableListGUI.Title("On Not Ammo Disable");
            ReorderableListGUI.ListField(GOList);

            EditorGUILayout.LabelField("", "Audio", "box");
            EditorGUILayout.BeginVertical("box");
            script.FireSound         = EditorGUILayout.ObjectField("Fire Sound", script.FireSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            script.TakeSound         = EditorGUILayout.ObjectField("Take Sound", script.TakeSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            script.SoundReloadByAnim = EditorGUILayout.Toggle("Sounds Reload By Animation", script.SoundReloadByAnim);
            if (!script.SoundReloadByAnim)
            {
                script.ReloadSound  = EditorGUILayout.ObjectField("Reload Begin", script.ReloadSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
                script.ReloadSound2 = EditorGUILayout.ObjectField("Reload Middle", script.ReloadSound2, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
                script.ReloadSound3 = EditorGUILayout.ObjectField("Reload End", script.ReloadSound3, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
            }
            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndVertical();
        serializedObject.ApplyModifiedProperties();
    }
예제 #25
0
        public virtual void DrawBlockGUI(Flowchart flowchart)
        {
            serializedObject.Update();

            // Execute any queued cut, copy, paste, etc. operations from the prevous GUI update
            // We need to defer applying these operations until the following update because
            // the ReorderableList control emits GUI errors if you clear the list in the same frame
            // as drawing the control (e.g. select all and then delete)
            if (Event.current.type == EventType.Layout)
            {
                foreach (Action action in actionList)
                {
                    if (action != null)
                    {
                        action();
                    }
                }
                actionList.Clear();
            }

            var block = target as Block;

            SerializedProperty commandListProperty = serializedObject.FindProperty("commandList");

            if (block == flowchart.SelectedBlock)
            {
                // Custom tinting
                SerializedProperty useCustomTintProp = serializedObject.FindProperty("useCustomTint");
                SerializedProperty tintProp          = serializedObject.FindProperty("tint");

                EditorGUILayout.BeginHorizontal();

                useCustomTintProp.boolValue = GUILayout.Toggle(useCustomTintProp.boolValue, " Custom Tint");
                if (useCustomTintProp.boolValue)
                {
                    EditorGUILayout.PropertyField(tintProp, GUIContent.none);
                }

                EditorGUILayout.EndHorizontal();

                SerializedProperty descriptionProp = serializedObject.FindProperty("description");
                EditorGUILayout.PropertyField(descriptionProp);

                DrawEventHandlerGUI(flowchart);

                block.UpdateIndentLevels();

                // Make sure each command has a reference to its parent block
                foreach (var command in block.CommandList)
                {
                    if (command == null) // Will be deleted from the list later on
                    {
                        continue;
                    }
                    command.ParentBlock = block;
                }

                ReorderableListGUI.Title("Commands");
                CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0);
                adaptor.nodeRect = block._NodeRect;

                ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu;

                if (block.CommandList.Count == 0)
                {
                    EditorGUILayout.HelpBox("Press the + button below to add a command to the list.", MessageType.Info);
                }
                else
                {
                    ReorderableListControl.DrawControlFromState(adaptor, null, flags);
                }

                // EventType.contextClick doesn't register since we moved the Block Editor to be inside
                // a GUI Area, no idea why. As a workaround we just check for right click instead.
                if (Event.current.type == EventType.mouseUp &&
                    Event.current.button == 1)
                {
                    ShowContextMenu();
                    Event.current.Use();
                }

                if (GUIUtility.keyboardControl == 0) //Only call keyboard shortcuts when not typing in a text field
                {
                    Event e = Event.current;

                    // Copy keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Copy")
                    {
                        if (flowchart.SelectedCommands.Count > 0)
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Copy")
                    {
                        actionList.Add(Copy);
                        e.Use();
                    }

                    // Cut keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Cut")
                    {
                        if (flowchart.SelectedCommands.Count > 0)
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Cut")
                    {
                        actionList.Add(Cut);
                        e.Use();
                    }

                    // Paste keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Paste")
                    {
                        CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance();
                        if (commandCopyBuffer.HasCommands())
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Paste")
                    {
                        actionList.Add(Paste);
                        e.Use();
                    }

                    // Duplicate keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Duplicate")
                    {
                        if (flowchart.SelectedCommands.Count > 0)
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Duplicate")
                    {
                        actionList.Add(Copy);
                        actionList.Add(Paste);
                        e.Use();
                    }

                    // Delete keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Delete")
                    {
                        if (flowchart.SelectedCommands.Count > 0)
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Delete")
                    {
                        actionList.Add(Delete);
                        e.Use();
                    }

                    // SelectAll keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "SelectAll")
                    {
                        e.Use();
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "SelectAll")
                    {
                        actionList.Add(SelectAll);
                        e.Use();
                    }
                }
            }

            // Remove any null entries in the command list.
            // This can happen when a command class is deleted or renamed.
            for (int i = commandListProperty.arraySize - 1; i >= 0; --i)
            {
                SerializedProperty commandProperty = commandListProperty.GetArrayElementAtIndex(i);
                if (commandProperty.objectReferenceValue == null)
                {
                    commandListProperty.DeleteArrayElementAtIndex(i);
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
        public void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            LayoutSettingsEditor.selectedTagIndex = -1;

            //property.serializedObject.Update();

            //var window = (property.serializedObject.targetObject as LayoutWindowType);
            this.Init(position, property.FindPropertyRelative("components"), new GUIContent("Components"));

            var enabledField = property.FindPropertyRelative("enabled");

            var scaleMode                    = property.FindPropertyRelative("scaleMode");
            var fixedScaleSize               = property.FindPropertyRelative("fixedScaleResolution");
            var matchWidthOrHeight           = property.FindPropertyRelative("matchWidthOrHeight");
            var layoutPreferences            = property.FindPropertyRelative("layoutPreferences");
            var allowCustomLayoutPreferences = property.FindPropertyRelative("allowCustomLayoutPreferences");
            var layout = property.FindPropertyRelative("layout");

            //if (EditorGUI.PropertyField(position, property, label, false) == true) {

            //++EditorGUI.indentLevel;

            EditorGUILayout.PropertyField(enabledField);
            EditorGUI.BeginDisabledGroup(!enabledField.boolValue);
            {
                CustomGUI.Splitter();

                {
                    var oldValue = layout.objectReferenceValue;
                    EditorGUILayout.PropertyField(layout, new GUIContent("Layout:"));
                    var newValue = layout.objectReferenceValue;
                    if (oldValue != newValue)
                    {
                        if (oldValue == null ||
                            EditorUtility.DisplayDialog("Layout Changing Warning",
                                                        "Do you really want to change this layout? Components list will be destroyed and the new one will be created. Are you sure?",
                                                        "Yes",
                                                        "No") == true)
                        {
                            this.canvasScalerEditor = null;
                            this.inited             = false;
                            GUI.changed             = true;
                            this.window.GetCurrentLayout().components = new UnityEngine.UI.Windows.Types.Layout.Component[0];
                            this.window.OnValidate();

                            property.serializedObject.ApplyModifiedProperties();
                        }
                    }
                }

                if (layout.objectReferenceValue != null || property.serializedObject.targetObject is FlowLayoutWindowTypeTemplate)
                {
                    CustomGUI.Splitter();

                    EditorGUILayout.PropertyField(scaleMode, new GUIContent("Scale Mode:"));

                    if (this.canvasScalerEditor == null)
                    {
                        var layoutSource = layout.objectReferenceValue as UnityEngine.UI.Windows.WindowLayout;
                        if (layoutSource != null && layoutSource.canvasScaler != null)
                        {
                            this.canvasScalerEditor = Editor.CreateEditor(layoutSource.canvasScaler);
                        }
                        else
                        {
                            this.canvasScalerEditor = null;
                        }
                    }

                    var mode = (UnityEngine.UI.Windows.WindowLayout.ScaleMode)System.Enum.GetValues(typeof(UnityEngine.UI.Windows.WindowLayout.ScaleMode)).GetValue(scaleMode.enumValueIndex);

                    if (layout.objectReferenceValue == null && property.serializedObject.targetObject is FlowLayoutWindowTypeTemplate)
                    {
                        EditorGUILayout.HelpBox("To use ScaleMode you need to setup `Layout` to store values. You can only use `Preferences` mode without `Layout`.", MessageType.Warning);

                        if (mode != UnityEngine.UI.Windows.WindowLayout.ScaleMode.Preferences)
                        {
                            mode = UnityEngine.UI.Windows.WindowLayout.ScaleMode.Preferences;
                            scaleMode.enumValueIndex = (int)mode;
                        }
                    }

                    EditorGUILayout.PropertyField(allowCustomLayoutPreferences, new GUIContent("Allow Custom Layout Preferences", "This option allows set up custom preferences by the code. If false code set up will do nothing."));

                    ++EditorGUI.indentLevel;

                    var enabled = true;
                    if (mode == UnityEngine.UI.Windows.WindowLayout.ScaleMode.Normal ||                     // Normal mode
                        mode == UnityEngine.UI.Windows.WindowLayout.ScaleMode.Fixed ||                      // Fixed mode
                        mode == UnityEngine.UI.Windows.WindowLayout.ScaleMode.Preferences)                  // Custom mode

                    {
                        if (mode == UnityEngine.UI.Windows.WindowLayout.ScaleMode.Fixed)
                        {
                            EditorGUILayout.PropertyField(fixedScaleSize, new GUIContent("Resolution:"));
                        }
                        else if (mode == UnityEngine.UI.Windows.WindowLayout.ScaleMode.Preferences)
                        {
                            EditorGUILayout.PropertyField(layoutPreferences, new GUIContent("File Link:"));
                            if (layoutPreferences.objectReferenceValue != null)
                            {
                                var obj        = new SerializedObject(layoutPreferences.objectReferenceValue);
                                var fixedScale = obj.FindProperty("fixedScale").boolValue;
                                fixedScaleSize.vector2Value   = obj.FindProperty("fixedScaleResolution").vector2Value;
                                matchWidthOrHeight.floatValue = obj.FindProperty("matchWidthOrHeight").floatValue;

                                if (fixedScale == true)
                                {
                                    mode = UnityEngine.UI.Windows.WindowLayout.ScaleMode.Fixed;
                                }
                                else
                                {
                                    mode = UnityEngine.UI.Windows.WindowLayout.ScaleMode.Normal;
                                }
                            }
                        }

                        var layoutSource = layout.objectReferenceValue as UnityEngine.UI.Windows.WindowLayout;
                        if (layoutSource != null)
                        {
                            layoutSource.SetScale(mode, fixedScaleSize.vector2Value, matchWidthOrHeight.floatValue);
                        }

                        enabled = false;
                    }

                    EditorGUI.BeginDisabledGroup(!enabled);
                    if (this.canvasScalerEditor != null)
                    {
                        this.canvasScalerEditor.OnInspectorGUI();
                    }
                    EditorGUI.EndDisabledGroup();

                    --EditorGUI.indentLevel;
                }

                CustomGUI.Splitter();

                if (this.inited == true && this.window != null && this.window.GetCurrentLayout().layout != null)
                {
                    ReorderableListGUI.Title("Components");
                    var lastRect = GUILayoutUtility.GetLastRect();
                    var rect     = new Rect(lastRect.x + lastRect.width - 100f - 4f, lastRect.y, 100f, lastRect.height);
                    if (GUI.Button(rect, "Refresh", EditorStyles.toolbarButton) == true)
                    {
                        var target = property.serializedObject.targetObject as LayoutWindowType;
                        target.OnValidateEditor();

                        this.Reset();
                    }
                    this.elements.Draw(this.adaptor);
                }
            }
            EditorGUI.EndDisabledGroup();

            //}

            //property.serializedObject.ApplyModifiedProperties();
        }
        public void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            //property.serializedObject.Update();

            //var window = (property.serializedObject.targetObject as LayoutWindowType);
            this.Init(position, property.FindPropertyRelative("components"), new GUIContent("Components"));

            var scaleMode          = property.FindPropertyRelative("scaleMode");
            var fixedScaleSize     = property.FindPropertyRelative("fixedScaleResolution");
            var matchWidthOrHeight = property.FindPropertyRelative("matchWidthOrHeight");
            var layoutPreferences  = property.FindPropertyRelative("layoutPreferences");
            var layout             = property.FindPropertyRelative("layout");

            if (EditorGUI.PropertyField(position, property, label, false) == true)
            {
                ++EditorGUI.indentLevel;

                var oldValue = layout.objectReferenceValue;
                EditorGUILayout.PropertyField(layout, new GUIContent("Layout:"));
                var newValue = layout.objectReferenceValue;
                if (oldValue != newValue)
                {
                    if (oldValue == null ||
                        EditorUtility.DisplayDialog("Layout Changing Warning",
                                                    "Do you really want to change this layout? Components list will be destroyed and the new one will be created. Are you sure?",
                                                    "Yes",
                                                    "No") == true)
                    {
                        this.canvasScalerEditor       = null;
                        this.inited                   = false;
                        GUI.changed                   = true;
                        this.window.layout.components = new UnityEngine.UI.Windows.Types.Layout.Component[0];
                        this.window.OnValidate();
                    }
                }

                if (layout.objectReferenceValue != null)
                {
                    CustomGUI.Splitter();

                    EditorGUILayout.PropertyField(scaleMode, new GUIContent("Scale Mode:"));

                    if (this.canvasScalerEditor == null)
                    {
                        var layoutSource = layout.objectReferenceValue as UnityEngine.UI.Windows.WindowLayout;
                        if (layoutSource != null && layoutSource.canvasScaler != null)
                        {
                            this.canvasScalerEditor = Editor.CreateEditor(layoutSource.canvasScaler);
                        }
                        else
                        {
                            this.canvasScalerEditor = null;
                        }
                    }

                    var mode = (UnityEngine.UI.Windows.WindowLayout.ScaleMode)System.Enum.GetValues(typeof(UnityEngine.UI.Windows.WindowLayout.ScaleMode)).GetValue(scaleMode.enumValueIndex);

                    var enabled = true;
                    if (mode == UnityEngine.UI.Windows.WindowLayout.ScaleMode.Normal ||                    // Normal mode
                        mode == UnityEngine.UI.Windows.WindowLayout.ScaleMode.Fixed ||                     // Fixed mode
                        mode == UnityEngine.UI.Windows.WindowLayout.ScaleMode.Preferences)                 // Custom mode

                    {
                        var layoutSource = layout.objectReferenceValue as UnityEngine.UI.Windows.WindowLayout;
                        if (layoutSource != null)
                        {
                            if (mode == UnityEngine.UI.Windows.WindowLayout.ScaleMode.Fixed)
                            {
                                EditorGUILayout.PropertyField(fixedScaleSize, new GUIContent("Resolution:"));
                            }
                            else if (mode == UnityEngine.UI.Windows.WindowLayout.ScaleMode.Preferences)
                            {
                                EditorGUILayout.PropertyField(layoutPreferences, new GUIContent("File Link:"));
                                if (layoutPreferences.objectReferenceValue != null)
                                {
                                    var obj        = new SerializedObject(layoutPreferences.objectReferenceValue);
                                    var fixedScale = obj.FindProperty("fixedScale").boolValue;
                                    fixedScaleSize.vector2Value   = obj.FindProperty("fixedScaleResolution").vector2Value;
                                    matchWidthOrHeight.floatValue = obj.FindProperty("matchWidthOrHeight").floatValue;

                                    if (fixedScale == true)
                                    {
                                        mode = UnityEngine.UI.Windows.WindowLayout.ScaleMode.Fixed;
                                    }
                                    else
                                    {
                                        mode = UnityEngine.UI.Windows.WindowLayout.ScaleMode.Normal;
                                    }
                                }
                            }

                            layoutSource.SetScale(mode, fixedScaleSize.vector2Value, matchWidthOrHeight.floatValue);
                        }
                        enabled = false;
                    }

                    EditorGUI.BeginDisabledGroup(!enabled);
                    if (this.canvasScalerEditor != null)
                    {
                        this.canvasScalerEditor.OnInspectorGUI();
                    }
                    EditorGUI.EndDisabledGroup();

                    CustomGUI.Splitter();
                }

                --EditorGUI.indentLevel;

                if (this.inited == true && this.window != null && this.window.layout.layout != null)
                {
                    if (GUILayout.Button("Reset") == true)
                    {
                        this.inited = false;
                    }

                    ReorderableListGUI.Title("Components");
                    this.elements.Draw(this.adapter);
                }
            }

            property.serializedObject.ApplyModifiedProperties();
        }
예제 #28
0
        public void DrawSequenceGUI(FungusScript fungusScript)
        {
            if (fungusScript.selectedSequence == null)
            {
                return;
            }

            serializedObject.Update();

            Sequence sequence = fungusScript.selectedSequence;

            EditorGUI.BeginChangeCheck();
            string sequenceName = EditorGUILayout.TextField(new GUIContent("Name", "Name of sequence object"), sequence.gameObject.name);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(sequence.gameObject, "Set Sequence Name");
                sequence.gameObject.name = sequenceName;
            }

            EditorGUILayout.PropertyField(descriptionProp);

            EditorGUILayout.Separator();

            UpdateIndentLevels(sequence);

            ReorderableListGUI.Title("Command Sequence");
            SerializedProperty commandListProperty = serializedObject.FindProperty("commandList");
            CommandListAdaptor adaptor             = new CommandListAdaptor(commandListProperty, 0);

            ReorderableListControl.DrawControlFromState(adaptor, null, 0);

            if (Application.isPlaying)
            {
                serializedObject.ApplyModifiedProperties();
                return;
            }

            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            if (fungusScript.copyCommand != null)
            {
                if (GUILayout.Button("Paste"))
                {
                    fungusScript.selectedCommand = CommandEditor.PasteCommand(fungusScript.copyCommand, fungusScript.selectedSequence);
                }
            }

            EditorGUILayout.EndHorizontal();

            if (fungusScript.selectedCommand != null)
            {
                CommandInfoAttribute infoAttr = CommandEditor.GetCommandInfo(fungusScript.selectedCommand.GetType());
                if (infoAttr != null)
                {
                    EditorGUILayout.HelpBox(infoAttr.HelpText, MessageType.Info);
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
예제 #29
0
        void DrawPlatforms(BuildConfiguration conf)
        {
            using (new IMGUIBlockWithIndent(new GUIContent("Platforms")))
            {
                using (new IMGUIBeginHorizontal())
                {
                    GUILayout.Space(20);
                    using (new IMGUIBeginVertical())
                    {
                        foreach (var platform in conf.Platforms)
                        {
                            m_ShowBuildIndex = conf.IsActive(platform);
                            EditorGUILayout.BeginHorizontal(GUI.skin.box);
                            {
                                EditorGUILayout.BeginVertical(GUILayout.Width(10));
                                {
                                    using (new IMGUIBeginHorizontal())
                                    {
                                        GUILayout.Space(2);
                                        bool delete = GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(18));
                                        if (delete)
                                        {
                                            conf.Platforms.Remove(platform);
                                            GUIUtility.ExitGUI();
                                            break;
                                        }

                                        GUILayout.Space(-5);
                                    }
                                }
                                EditorGUILayout.EndVertical();

                                EditorGUILayout.BeginVertical(GUILayout.Width(150));
                                {
                                    ReorderableListGUI.Title("Build Targets");

                                    ReorderableListGUI.ListField(platform.BuildTargets, BuildTargetListItem, DrawEmptyPlatform);
                                }
                                EditorGUILayout.EndVertical();

                                EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                                {
                                    GUI.backgroundColor = m_ShowBuildIndex ? GUI.skin.settings.selectionColor : Color.white;
                                    ReorderableListGUI.Title("Scenes");
                                    GUI.backgroundColor = Color.white;

                                    ReorderableListGUI.ListField(platform.Scenes, ContentTypeListItem, DrawEmptyScene);
                                }
                                EditorGUILayout.EndVertical();
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }

                using (new IMGUIBeginHorizontal())
                {
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("+", GUILayout.Width(25)))
                    {
                        PlatformsConfiguration s = new PlatformsConfiguration();
                        conf.Platforms.Add(s);
                    }
                }
            }

            m_ShowBuildIndex = true;
        }
예제 #30
0
 private void DrawStatesList()
 {
     ReorderableListGUI.Title("States");
     ReorderableListGUI.ListField(states);
 }