示例#1
0
        private static void InitStyles()
        {
            defaultTitleStyle                   = new GUIStyle();
            defaultTitleStyle.border            = new RectOffset(2, 2, 2, 1);
            defaultTitleStyle.margin            = new RectOffset(5, 5, 5, 0);
            defaultTitleStyle.padding           = new RectOffset(5, 5, 0, 0);
            defaultTitleStyle.alignment         = TextAnchor.MiddleLeft;
            defaultTitleStyle.normal.background = ReorderableListResources.texTitleBackground;
            defaultTitleStyle.normal.textColor  = EditorGUIUtility.isProSkin
                                ? new Color(0.8f, 0.8f, 0.8f)
                                : new Color(0.2f, 0.2f, 0.2f);

            defaultContainerStyle                   = new GUIStyle();
            defaultContainerStyle.border            = new RectOffset(2, 2, 1, 2);
            defaultContainerStyle.margin            = new RectOffset(5, 5, 5, 5);
            defaultContainerStyle.padding           = new RectOffset(1, 1, 2, 2);
            defaultContainerStyle.normal.background = ReorderableListResources.texContainerBackground;

            defaultAddButtonStyle                   = new GUIStyle();
            defaultAddButtonStyle.fixedWidth        = 30;
            defaultAddButtonStyle.fixedHeight       = 16;
            defaultAddButtonStyle.normal.background = ReorderableListResources.texAddButton;
            defaultAddButtonStyle.active.background = ReorderableListResources.texAddButtonActive;

            defaultRemoveButtonStyle                   = new GUIStyle();
            defaultRemoveButtonStyle.fixedWidth        = 27;
            defaultRemoveButtonStyle.active.background = ReorderableListResources.CreatePixelTexture("Dark Pixel (List GUI)", new Color32(18, 18, 18, 255));
            defaultRemoveButtonStyle.imagePosition     = ImagePosition.ImageOnly;
            defaultRemoveButtonStyle.alignment         = TextAnchor.MiddleCenter;
        }
示例#2
0
        static ReorderableListStyles()
        {
            Title                   = new GUIStyle();
            Title.border            = new RectOffset(2, 2, 2, 1);
            Title.margin            = new RectOffset(5, 5, 5, 0);
            Title.padding           = new RectOffset(5, 5, 3, 3);
            Title.alignment         = TextAnchor.MiddleLeft;
            Title.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.TitleBackground);
            Title.normal.textColor  = EditorGUIUtility.isProSkin
                ? new Color(0.8f, 0.8f, 0.8f)
                : new Color(0.2f, 0.2f, 0.2f);

            Container                   = new GUIStyle();
            Container.border            = new RectOffset(2, 2, 2, 2);
            Container.margin            = new RectOffset(5, 5, 0, 0);
            Container.padding           = new RectOffset(2, 2, 2, 2);
            Container.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.ContainerBackground);

            Container2 = new GUIStyle(Container);
            Container2.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.Container2Background);

            FooterButton                   = new GUIStyle();
            FooterButton.fixedHeight       = 18;
            FooterButton.alignment         = TextAnchor.MiddleCenter;
            FooterButton.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.Button_Normal);
            FooterButton.active.background = ReorderableListResources.GetTexture(ReorderableListTexture.Button_Active);
            FooterButton.border            = new RectOffset(3, 3, 1, 3);
            FooterButton.padding           = new RectOffset(2, 2, 0, 2);
            FooterButton.clipping          = TextClipping.Overflow;

            FooterButton2                   = new GUIStyle();
            FooterButton2.fixedHeight       = 18;
            FooterButton2.alignment         = TextAnchor.MiddleCenter;
            FooterButton2.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.Button2_Normal);
            FooterButton2.active.background = ReorderableListResources.GetTexture(ReorderableListTexture.Button2_Active);
            FooterButton2.border            = new RectOffset(3, 3, 3, 3);
            FooterButton2.padding           = new RectOffset(2, 2, 2, 2);
            FooterButton2.clipping          = TextClipping.Overflow;

            ItemButton = new GUIStyle();

            string name = $"{EmbeddedResourceProvider.VISUAL_SCRIPTING_PACKAGE}.Dark Pixel (List GUI)";

            Texture2D background = EmbeddedResourceProvider.CreatePixelTexture(name, new Color32(18, 18, 18, 255), 1, 1);

            ItemButton.active.background = background;
            ItemButton.imagePosition     = ImagePosition.ImageOnly;
            ItemButton.alignment         = TextAnchor.MiddleCenter;
            ItemButton.overflow          = new RectOffset(0, 0, -1, 0);
            ItemButton.padding           = new RectOffset(0, 0, 1, 0);
            ItemButton.contentOffset     = new Vector2(0, -1f);

            SelectedItem = new GUIStyle();
            SelectedItem.normal.background = ReorderableListResources.texHighlightColor;
            SelectedItem.normal.textColor  = Color.white;
            SelectedItem.fontSize          = 12;
        }
示例#3
0
        private static void InitStyles()
        {
            defaultTitleStyle = new GUIStyle {
                border    = new RectOffset(2, 2, 2, 1),
                margin    = new RectOffset(5, 5, 5, 0),
                padding   = new RectOffset(5, 5, 0, 0),
                alignment = TextAnchor.MiddleLeft,
                normal    =
                {
                    //background = ReorderableListResources.texTitleBackground,
                    //textColor = EditorGUIUtility.isProSkin
                    //    ? new Color(0.8f, 0.8f, 0.8f)
                    //    : new Color(0.2f, 0.2f, 0.2f)
                }
            };

            defaultContainerStyle = new GUIStyle {
                border  = new RectOffset(2, 2, 1, 2),
                margin  = new RectOffset(5, 5, 5, 5),
                padding = new RectOffset(1, 1, 3, 2),
                normal  = { background = ReorderableListResources.texContainerBackground }
            };

            defaultAddButtonStyle = new GUIStyle {
                fixedWidth  = 30,
                fixedHeight = 16,
                normal      = { background = ReorderableListResources.texAddButtonFlipped },
                active      = { background = ReorderableListResources.texAddButtonActiveFlipped }
            };

            defaultAddButtonStyleFlipped = new GUIStyle {
                fixedWidth  = 30,
                fixedHeight = 16,
                normal      = { background = ReorderableListResources.texAddButton },
                active      = { background = ReorderableListResources.texAddButtonActive }
            };

            defaultAddButtonStyleIndependent = new GUIStyle {
                fixedWidth  = 30,
                fixedHeight = 16,
                normal      = { background = ReorderableListResources.texAddButtonIndependent },
                active      = { background = ReorderableListResources.texAddButtonActive }
            };


            defaultRemoveButtonStyle = new GUIStyle {
                fixedWidth = 27,
                active     =
                {
                    background =
                        ReorderableListResources.CreatePixelTexture("Dark Pixel (List GUI)",
                                                                    new Color32(18, 18, 18, 255))
                },
                imagePosition = ImagePosition.ImageOnly,
                alignment     = TextAnchor.MiddleCenter
            };
        }
        static ReorderableListStyles()
        {
            Title                   = new GUIStyle();
            Title.border            = new RectOffset(2, 2, 2, 1);
            Title.margin            = new RectOffset(5, 5, 5, 0);
            Title.padding           = new RectOffset(5, 5, 0, 0);
            Title.alignment         = TextAnchor.MiddleLeft;
            Title.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.TitleBackground);
            Title.normal.textColor  = EditorGUIUtility.isProSkin
                                ? new Color(0.8f, 0.8f, 0.8f)
                                : new Color(0.2f, 0.2f, 0.2f);

            Container                   = new GUIStyle();
            Container.border            = new RectOffset(2, 2, 1, 2);
            Container.margin            = new RectOffset(5, 5, 5, 5);
            Container.padding           = new RectOffset(1, 1, 2, 2);
            Container.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.ContainerBackground);

            Container2 = new GUIStyle(Container);
            Container2.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.Container2Background);

            FooterButton                   = new GUIStyle();
            FooterButton.fixedHeight       = 16;
            FooterButton.alignment         = TextAnchor.MiddleCenter;
            FooterButton.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.Button_Normal);
            FooterButton.active.background = ReorderableListResources.GetTexture(ReorderableListTexture.Button_Active);
            FooterButton.border            = new RectOffset(3, 3, 1, 3);
            FooterButton.padding           = new RectOffset(2, 2, 0, 2);
            FooterButton.clipping          = TextClipping.Overflow;

            FooterButton2                   = new GUIStyle();
            FooterButton2.fixedHeight       = 18;
            FooterButton2.alignment         = TextAnchor.MiddleCenter;
            FooterButton2.normal.background = ReorderableListResources.GetTexture(ReorderableListTexture.Button2_Normal);
            FooterButton2.active.background = ReorderableListResources.GetTexture(ReorderableListTexture.Button2_Active);
            FooterButton2.border            = new RectOffset(3, 3, 3, 3);
            FooterButton2.padding           = new RectOffset(2, 2, 2, 2);
            FooterButton2.clipping          = TextClipping.Overflow;

            ItemButton = new GUIStyle();
            ItemButton.active.background = ReorderableListResources.CreatePixelTexture("Dark Pixel (List GUI)", new Color32(18, 18, 18, 255));
            ItemButton.imagePosition     = ImagePosition.ImageOnly;
            ItemButton.alignment         = TextAnchor.MiddleCenter;

            SelectedItem = new GUIStyle();
            SelectedItem.normal.background = ReorderableListResources.texHighlightColor;
            SelectedItem.normal.textColor  = Color.white;
            SelectedItem.fontSize          = 12;
        }
    private void DrawObservedComponentsList()
    {
        GUILayout.Space(5);
        SerializedProperty listProperty = serializedObject.FindProperty("ObservedComponents");

        if (listProperty == null)
        {
            return;
        }

        float containerElementHeight = 22;
        float containerHeight        = listProperty.arraySize * containerElementHeight;

        bool isOpen = PhotonGUI.ContainerHeaderFoldout("Observed Components (" + GetObservedComponentsCount() + ")", serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue);

        serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue = isOpen;

        if (isOpen == false)
        {
            containerHeight = 0;
        }

        //Texture2D statsIcon = AssetDatabase.LoadAssetAtPath( "Assets/Photon Unity Networking/Editor/PhotonNetwork/PhotonViewStats.png", typeof( Texture2D ) ) as Texture2D;

        Rect containerRect = PhotonGUI.ContainerBody(containerHeight);
        bool wasObservedComponentsEmpty = this.m_Target.ObservedComponents.FindAll(item => item != null).Count == 0;

        if (isOpen == true)
        {
            for (int i = 0; i < listProperty.arraySize; ++i)
            {
                Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin + containerElementHeight * i, containerRect.width, containerElementHeight);
                {
                    Rect texturePosition = new Rect(elementRect.xMin + 6, elementRect.yMin + elementRect.height / 2f - 1, 9, 5);
                    ReorderableListResources.DrawTexture(texturePosition, ReorderableListResources.texGrabHandle);

                    Rect propertyPosition = new Rect(elementRect.xMin + 20, elementRect.yMin + 3, elementRect.width - 45, 16);
                    EditorGUI.PropertyField(propertyPosition, listProperty.GetArrayElementAtIndex(i), new GUIContent());

                    //Debug.Log( listProperty.GetArrayElementAtIndex( i ).objectReferenceValue.GetType() );
                    //Rect statsPosition = new Rect( propertyPosition.xMax + 7, propertyPosition.yMin, statsIcon.width, statsIcon.height );
                    //ReorderableListResources.DrawTexture( statsPosition, statsIcon );

                    Rect removeButtonRect = new Rect(elementRect.xMax - PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
                                                     elementRect.yMin + 2,
                                                     PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
                                                     PhotonGUI.DefaultRemoveButtonStyle.fixedHeight);

                    GUI.enabled = listProperty.arraySize > 1;
                    if (GUI.Button(removeButtonRect, new GUIContent(ReorderableListResources.texRemoveButton), PhotonGUI.DefaultRemoveButtonStyle))
                    {
                        listProperty.DeleteArrayElementAtIndex(i);
                    }
                    GUI.enabled = true;

                    if (i < listProperty.arraySize - 1)
                    {
                        texturePosition = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1);
                        PhotonGUI.DrawSplitter(texturePosition);
                    }
                }
            }
        }

        if (PhotonGUI.AddButton())
        {
            listProperty.InsertArrayElementAtIndex(Mathf.Max(0, listProperty.arraySize - 1));
        }

        serializedObject.ApplyModifiedProperties();

        bool isObservedComponentsEmpty = this.m_Target.ObservedComponents.FindAll(item => item != null).Count == 0;

        if (wasObservedComponentsEmpty == true && isObservedComponentsEmpty == false && this.m_Target.synchronization == ViewSynchronization.Off)
        {
            Undo.RecordObject(this.m_Target, "Change PhotonView");
            this.m_Target.synchronization = ViewSynchronization.UnreliableOnChange;
            #if !UNITY_MIN_5_3
            EditorUtility.SetDirty(this.m_Target);
            #endif
            serializedObject.Update();
        }

        if (wasObservedComponentsEmpty == false && isObservedComponentsEmpty == true)
        {
            Undo.RecordObject(this.m_Target, "Change PhotonView");
            this.m_Target.synchronization = ViewSynchronization.Off;
            #if !UNITY_MIN_5_3
            EditorUtility.SetDirty(this.m_Target);
            #endif
            serializedObject.Update();
        }
    }
示例#6
0
 public static void DrawSplitter(Rect position)
 {
     ReorderableListResources.DrawTexture(position, ReorderableListResources.texItemSplitter);
 }
        public void Draw(string label, IList list, System.Action onAdd, System.Action <object> onEach = null, bool addButton = true, bool removeButton = true, int maxCount = -1, int minCount = -1)
        {
            var backStyle = ME.Utilities.CacheStyle("UI.Windows.ABTesting.Back", "Back", (name) => {
                var _style        = new GUIStyle("LargeButtonLeft");
                _style.fixedWidth = 0f;
                return(_style);
            });
            var removeButtonStyle = ME.Utilities.CacheStyle("UI.Windows.ABTesting.RemoveButton", "Remove", (name) => {
                var _style         = new GUIStyle("LargeButtonRight");
                _style.fixedWidth  = 30f;
                _style.fixedHeight = 30f;
                return(_style);
            });
            var addButtonStyle = ME.Utilities.CacheStyle("UI.Windows.ABTesting.AddButton", "Add", (name) => {
                var _style        = new GUIStyle("Button");
                _style.fixedWidth = 30f;
                return(_style);
            });
            var centeredLabel = ME.Utilities.CacheStyle("UI.Windows.ABTesting.CenteredLabel", "CenteredLabel", (name) => {
                var _style    = new GUIStyle(EditorStyles.centeredGreyMiniLabel);
                _style.margin = new RectOffset(0, 30, 0, 0);
                return(_style);
            });


            GUILayout.BeginVertical();
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(label, EditorStyles.boldLabel);

                    GUILayout.FlexibleSpace();

                    if (addButton == true)
                    {
                        var iconAddNormal = ReorderableListResources.GetTexture(ReorderableListTexture.Icon_Add_Normal);
                        if (GUILayout.Button(iconAddNormal, addButtonStyle) == true)
                        {
                            onAdd();
                        }
                    }
                }
                GUILayout.EndHorizontal();

                if (maxCount >= 0)
                {
                    if (list.Count > maxCount)
                    {
                        list.RemoveAt(list.Count - 1);
                    }
                }

                if (minCount >= 0)
                {
                    if (list.Count < minCount)
                    {
                        onAdd();
                    }
                }

                for (int i = 0; i < list.Count; ++i)
                {
                    var item = list[i];
                    if (onEach != null)
                    {
                        onEach(item);
                    }

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.BeginVertical(backStyle);
                        {
                            (item as IBaseCondition).OnGUI();
                        }
                        GUILayout.EndVertical();

                        if (removeButton == true)
                        {
                            var iconNormal = ReorderableListResources.GetTexture(ReorderableListTexture.Icon_Remove_Normal);
                            if (GUILayout.Button(iconNormal, removeButtonStyle) == true)
                            {
                                list.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (i < list.Count - 1)
                    {
                        GUILayout.Label("- OR -", centeredLabel);
                    }
                }
            }
            GUILayout.EndHorizontal();
        }
示例#8
0
    void DrawNetworkGunsList()
    {
        GUILayout.Space(5);
        SerializedProperty listProperty = serializedObject.FindProperty("NetworkGuns");

        if (listProperty == null)
        {
            return;
        }

        float containerElementHeight = 22;
        float containerHeight        = listProperty.arraySize * containerElementHeight;

        bool isOpen = PhotonGUI.ContainerHeaderFoldout("Networ Guns (" + GetGunsCount() + ")", serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue);

        serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue = isOpen;

        if (isOpen == false)
        {
            containerHeight = 0;
        }

        Rect containerRect = PhotonGUI.ContainerBody(containerHeight);

        if (isOpen == true)
        {
            for (int i = 0; i < listProperty.arraySize; ++i)
            {
                Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin + containerElementHeight * i, containerRect.width, containerElementHeight);
                {
                    Rect texturePosition = new Rect(elementRect.xMin + 6, elementRect.yMin + elementRect.height / 2f - 1, 9, 5);
                    ReorderableListResources.DrawTexture(texturePosition, ReorderableListResources.texGrabHandle);

                    Rect propertyPosition = new Rect(elementRect.xMin + 20, elementRect.yMin + 3, elementRect.width - 45, 16);
                    EditorGUI.PropertyField(propertyPosition, listProperty.GetArrayElementAtIndex(i), new GUIContent());

                    Rect removeButtonRect = new Rect(elementRect.xMax - PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
                                                     elementRect.yMin + 2,
                                                     PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
                                                     PhotonGUI.DefaultRemoveButtonStyle.fixedHeight);

                    GUI.enabled = listProperty.arraySize > 1;
                    if (GUI.Button(removeButtonRect, new GUIContent(ReorderableListResources.texRemoveButton), PhotonGUI.DefaultRemoveButtonStyle))
                    {
                        listProperty.DeleteArrayElementAtIndex(i);
                    }
                    GUI.enabled = true;

                    if (i < listProperty.arraySize - 1)
                    {
                        texturePosition = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1);
                        PhotonGUI.DrawSplitter(texturePosition);
                    }
                }
            }
        }

        if (PhotonGUI.AddButton())
        {
            listProperty.InsertArrayElementAtIndex(Mathf.Max(0, listProperty.arraySize - 1));
        }

        serializedObject.ApplyModifiedProperties();
    }