Esempio n. 1
0
        protected virtual void SelectBuilder(ProjectBuilder[] builders)
        {
            // Get all scenes in build from BuildSettings.
            s_AvailableScenes = EditorBuildSettings.scenes.Select(x => Path.GetFileName(x.path)).ToArray();

            // Get all builder assets in project.
            s_BuildersInProject = new List <ProjectBuilder>(
                ProjectBuilderUtil.GetAssets <ProjectBuilder>()
                .OrderBy(b => b.BuildApplication)
                .ThenBy(b => b.ActualBuildTarget)
                );

            _targets = 0 < builders.Length
                ? builders
                : s_BuildersInProject.Take(1).ToArray();

            _serializedObject = null;

            contentTitle.text = 0 < _targets.Length
                ? _targets.Select(x => "  " + x.name).Aggregate((a, b) => a + "\n" + b)
                : "";

            // 最後に選択したビルダーアセットを記憶.
            var lastSelected = _targets.FirstOrDefault(x => x.ActualBuildTarget == EditorUserBuildSettings.activeBuildTarget);

            if (lastSelected)
            {
                PlayerPrefs.SetString(kPrefsKeyLastSelected + EditorUserBuildSettings.activeBuildTarget,
                                      AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(lastSelected)));
                PlayerPrefs.Save();
            }
        }
Esempio n. 2
0
        //---- ▲ GUIキャッシュ ▲ ----

        //-------------------------------
        //	Unityコールバック.
        //-------------------------------
        /// <summary>
        /// Raises the enable event.
        /// </summary>
        protected virtual void OnEnable()
        {
            _targets = null;

            // 最後に選択したビルダーが存在する.
            string path =
                AssetDatabase.GUIDToAssetPath(
                    PlayerPrefs.GetString(kPrefsKeyLastSelected + EditorUserBuildSettings.activeBuildTarget));

            if (!string.IsNullOrEmpty(path))
            {
                var builder = AssetDatabase.LoadAssetAtPath <ProjectBuilder>(path);
                if (builder)
                {
                    SelectBuilder(new[] { builder });
                }
            }

            if (_targets == null)
            {
                // 選択しているオブジェクト内にビルダーが存在する
                if (Selection.objects.OfType <ProjectBuilder>().Any())
                {
                    SelectBuilder(Selection.objects.OfType <ProjectBuilder>().ToArray());
                }
                else
                {
                    // プロジェクト内にビルダーが存在する
                    var builders = ProjectBuilderUtil.GetAssets <ProjectBuilder>();

                    if (builders.Any())
                    {
                        SelectBuilder(builders.Take(1).ToArray());
                    }
                }
            }

            Selection.selectionChanged += OnSelectionChanged;
            minSize = new Vector2(300, 300);
        }
Esempio n. 3
0
        protected virtual void Initialize()
        {
            if (styleCommand != null)
            {
                return;
            }

            styleTitle              = new GUIStyle("IN BigTitle");
            styleTitle.alignment    = TextAnchor.UpperLeft;
            styleTitle.fontSize     = 12;
            styleTitle.stretchWidth = true;
            styleTitle.margin       = new RectOffset();

            styleSymbols          = new GUIStyle(EditorStyles.textArea);
            styleSymbols.wordWrap = true;

            styleCommand = new GUIStyle(EditorStyles.textArea);
            styleCommand.stretchWidth = false;
            styleCommand.fontSize     = 9;
            contentOpen = new GUIContent(EditorGUIUtility.FindTexture("project"));

            // Find end property in ProjectBuilder.
            var dummy = ScriptableObject.CreateInstance <ProjectBuilder>();
            var sp    = new SerializedObject(dummy).GetIterator();

            sp.Next(true);

            while (sp.Next(false))
            {
                s_EndBasePropertyName = sp.name;
            }

            // Scene list.
            roSceneList = new ReorderableList(new List <ProjectBuilder.SceneSetting>(),
                                              typeof(ProjectBuilder.SceneSetting));
            roSceneList.drawElementCallback += DrawScenesList;

            roSceneList.headerHeight  = 0;
            roSceneList.elementHeight = 18;

            // Exclude Directories List
            roExcludeDirectoriesList = new ReorderableList(new List <string>(), typeof(string));
            roExcludeDirectoriesList.drawElementCallback += DrawExcludeDirectoriesList;

            roExcludeDirectoriesList.headerHeight  = 0;
            roExcludeDirectoriesList.elementHeight = 18;

            // Builder list.
            roBuilderList = new ReorderableList(s_BuildersInProject, typeof(ProjectBuilder));
            roBuilderList.onSelectCallback = (list) => Selection.activeObject = list.list[list.index] as ProjectBuilder;

            roBuilderList.onAddCallback += OnAddBuilderItem;

            roBuilderList.onRemoveCallback += OnRemoveBuilderItem;

            roBuilderList.drawElementCallback += DrawBuildersList;

            roBuilderList.headerHeight = 0;
            roBuilderList.draggable    = false;

            contentTitle =
                new GUIContent(ProjectBuilderUtil.GetAssets <Texture2D>(typeof(ProjectBuilder).Name + " Icon").FirstOrDefault());

            DestroyImmediate(dummy);
        }