示例#1
0
        private void OnGUI()
        {
            if (focusedWindow != this)
            {
                Close();
                instance = null;
            }

            if (names == null)
            {
                names = serializer.Select(t => t.Name).ToArray();
            }

            EditorGUILayout.LabelField("Select the serializer you want to use:");
            selected = EditorGUILayout.Popup("", selected, names);

            if (GUILayout.Button("Import"))
            {
                closeAction.Invoke(serializer[selected]);
                Close();
            }

            if (GUILayout.Button("Cancel"))
            {
                Close();
            }
        }
示例#2
0
        private static void ImportTraining()
        {
            string path = EditorUtility.OpenFilePanel("Select your training", ".", String.Empty);

            if (string.IsNullOrEmpty(path) || Directory.Exists(path))
            {
                return;
            }

            string format = Path.GetExtension(path).Replace(".", "");
            List <ICourseSerializer> result = GetFittingSerializer(format);

            if (result.Count == 0)
            {
                Debug.LogError("Tried to import, but no Serializer found.");
                return;
            }

            if (result.Count == 1)
            {
                CourseAssetManager.Import(path, result.First());
            }
            else
            {
                ChooseSerializerPopup.Show(result, (serializer) =>
                {
                    CourseAssetManager.Import(path, serializer);
                });
            }
        }
示例#3
0
        /// <summary>
        /// Show the popup.
        /// </summary>
        /// <param name="serializer">Selectable serializer</param>
        /// <param name="closeAction">Action which will be invoked when closed successfully.</param>
        public static void Show(List <ICourseSerializer> serializer, Action <ICourseSerializer> closeAction)
        {
            if (instance != null)
            {
                instance.Close();
            }

            instance             = CreateInstance <ChooseSerializerPopup>();
            instance.serializer  = serializer;
            instance.closeAction = closeAction;

            Rect position = new Rect(0, 0, 320, 92);

            position.center   = new Rect(0f, 0f, Screen.currentResolution.width, Screen.currentResolution.height).center;
            instance.position = position;

            instance.ShowPopup();
            instance.Focus();
        }