예제 #1
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.Separator();

            GUI.enabled = true;

            GUILayout.BeginVertical(GUI.skin.box);
            GUILayout.Space(2.5f);

            // Var ExpansionName
            GUILayout.BeginHorizontal();
            GUILayout.Label("Expansion Name");

            if (GUILayout.Button(_target.ExpansionName))
            {
                string[] expansionsName = null;
                try
                {
                    expansionsName = Directory.GetDirectories("Assets/Bundles/Expansions/");
                    expansionsName = PYBundleBuildWindow.GetLastNameFromPaths(new List <string>(expansionsName));
                }
                catch { }
                PYSelectorWindow.Init(_rectSelectorWindow, _target.ExpansionName, expansionsName, (selectedItem) =>
                {
                    _target.ExpansionName = selectedItem.Value;
                });
            }

            if (Event.current.type == EventType.Repaint)
            {
                _rectSelectorWindow = GUILayoutUtility.GetLastRect();
            }
            GUILayout.EndHorizontal();

            // Var Language
            GUILayout.BeginHorizontal();
            GUILayout.Label("Language");

            Rect rectButton = GUILayoutUtility.GetRect(new GUIContent(_target.Language), GUI.skin.button);

            if (GUI.Button(rectButton, _target.Language))
            {
                string[] languagesName = null;
                try
                {
                    languagesName = Directory.GetDirectories("Assets/Bundles/Global/Localization/");
                    languagesName = PYBundleBuildWindow.GetLastNameFromPaths(new List <string>(languagesName));
                }
                catch { }
                PYSelectorWindow.Init(rectButton, _target.Language, languagesName, (selectedItem) =>
                {
                    _target.Language = selectedItem.Value;
                });
            }

            GUILayout.EndHorizontal();

            GUI.enabled = false;
            // Var IsReady
            _target.State = (PYBundleManagerState)EditorGUILayout.EnumPopup("State", _target.State);

            GUILayout.Space(2.5f);
            GUILayout.EndVertical();

            EditorGUILayout.Separator();
            GUI.enabled = true;

            if (GUILayout.Button("Build Bundle Assets Tags"))
            {
                BuildAssetTags();
            }

            EditorUtility.SetDirty(_target);
            EditorUtility.SetDirty(_target.gameObject);
        }
예제 #2
0
        void ShowPYPlayer(PYPlayer elem)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            elem.IsShowingElement = EditorGUILayout.Foldout(elem.IsShowingElement, string.Format(AUDIO_ITEM_NAME, elem.Name, elem.GetType().ToString()));
            if (GUILayout.Button("-", GUILayout.Width(40)))
            {
                Undo.RecordObject(target, "Removed Elem");
                _target.Audios.Remove(elem);

                EditorUtility.SetDirty(target);
                return;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            GUILayout.BeginVertical();
            if (elem.IsShowingElement)
            {
                if (elem is PYPlayerTag)
                {
                    PYPlayerTag playerTag = (PYPlayerTag)elem;
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("PYAudio Tag");
                    if (GUILayout.Button(playerTag.Tag.ToString()))
                    {
                        PYSelectorWindow.Init(_rectButtonTag, playerTag.Tag.ToString(),
                                              Enum.GetNames(typeof(PYAudioTags)), (selectedItem) =>
                        {
                            playerTag.Tag = (PYAudioTags)Enum.Parse(typeof(PYAudioTags), selectedItem.Value);
                        });
                    }

                    GUILayout.EndHorizontal();
                }
                else if (elem is PYPlayerClip)
                {
                    PYPlayerClip playerClip = (PYPlayerClip)elem;
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Asset Tag");
                    string tag = string.IsNullOrEmpty(playerClip.AssetTag.UnprocessedTag) ?
                                 "None" : playerClip.AssetTag.UnprocessedTag.Split(':')[0];
                    if (GUILayout.Button(tag))
                    {
                        string[] tags = PYBundleManager.GetAssetsTag();
                        tags = tags.Where(t => t.Contains(": Audio")).ToArray();

                        PYSelectorWindow.Init(_rectButtonTag, tag, tags, (selectedItem) =>
                        {
                            playerClip.AssetTag.UnprocessedTag = selectedItem.Value;
                        });
                    }

                    GUILayout.EndHorizontal();
                }

                if (Event.current.type == EventType.Repaint)
                {
                    _rectButtonTag = GUILayoutUtility.GetLastRect();
                }

                elem.DrawInspector();
                GUILayout.Space(5);
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
예제 #3
0
        // Draw the property inside the given rect
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // Using BeginProperty / EndProperty on the parent property means that
            // prefab override logic works on the entire property.
            EditorGUI.BeginProperty(position, label, property);

            // Draw label
            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            // Don't make child fields be indented
            var indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            // Calculate rects
            var tagButtonRect = new Rect(position.x, position.y, position.width, position.height);

            SerializedProperty unprocessedTag = property.FindPropertyRelative("UnprocessedTag");
            string             tag            = string.IsNullOrEmpty(unprocessedTag.stringValue) ?
                                                "None" : unprocessedTag.stringValue.Split(':')[0];

            if (GUI.Button(tagButtonRect, tag))
            {
                string[] tags = PYBundleManager.GetAssetsTag();

                _currentType = PYBundleManager.GetTypeByRealType(property.serializedObject.targetObject);
                if (!string.IsNullOrEmpty(_currentType))
                {
                    tags = tags.Where(FilterTag).ToArray();
                }

                // Create a description for each tag, if exist any
                string[] tagsDescriptions = new string[tags.Length];
                for (int x = 0; x < tags.Length; x++)
                {
                    string[] tagSplit = tags[x].Split(new string[] { "<||>" }, StringSplitOptions.None);

                    if (tagSplit.Length > 1)
                    {
                        tags[x]             = tagSplit[0];
                        tagsDescriptions[x] = tagSplit[1];
                    }
                    else
                    {
                        tagsDescriptions[x] = "";
                    }
                }

                PYSelectorWindow.Init(tagButtonRect, tag, tags,
                                      tagsDescriptions, (selectedItem) =>
                {
                    unprocessedTag.stringValue = selectedItem.Value;

                    property.serializedObject.ApplyModifiedProperties();
                    property.serializedObject.Update();
                });
            }

            // Set indent back to what it was
            EditorGUI.indentLevel = indent;

            EditorGUI.EndProperty();
        }