Skip to content

Commit

Permalink
Added exclusion path work, v1.1.0 bump
Browse files Browse the repository at this point in the history
  • Loading branch information
jzapdot committed Jun 12, 2019
2 parents 541dc65 + cefb705 commit 3cfb776
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

using UnityEngine;

namespace JCMG.PackageTools.Editor
{
/// <summary>
Expand All @@ -38,6 +41,8 @@ internal static class EditorConstants
public const string AssetExtension = ".asset";
public const string MetaFormat = "{0}.meta";
public const string GeneratedFolderName = "Generated";
public static readonly string ProjectPath =
Application.dataPath.Remove(Application.dataPath.Length - 6, 6);

// Icons
public const string EditorFolderIcon = "Folder Icon";
Expand All @@ -51,6 +56,8 @@ internal static class EditorConstants
public const string SourcePathsHeaderLabel = "Source Paths";
public const string SourcePathElementLabelFormat = "Path {0}:";

public const string IgnorePathsHeaderLabel = "Exclude Paths";

public const string KeywordsHeaderLabel = "Keywords";
public const string KeywordElementLabelFormat = "Keyword {0}:";

Expand All @@ -73,5 +80,6 @@ internal static class EditorConstants

public const string PackageUpdateSuccessFormat =
"[Package Tools] Successfully updated package source for [{0}].";

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ namespace JCMG.PackageTools.Editor
internal sealed class PackageManifestConfigInspector : UnityEditor.Editor
{
private ReorderableList _sourcePathsReorderableList;
private ReorderableList _excludePathsReorderableList;
private ReorderableList _keywordReorderableList;
private ReorderableList _dependenciesReorderableList;

private const string SourcePathsPropertyName = "packageSourcePaths";
private const string ExcludePathsPropertyName = "packageIgnorePaths";
private const string DestinationPathPropertyName = "packageDestinationPath";
private const string NamePropertyName = "packageName";
private const string DisplayNameProperty = "displayName";
Expand All @@ -57,6 +59,15 @@ private void OnEnable()
elementHeight = EditorConstants.FolderPathPickerHeight
};

_excludePathsReorderableList = new ReorderableList(
serializedObject,
serializedObject.FindProperty(ExcludePathsPropertyName))
{
drawHeaderCallback = DrawExcludePathHeader,
drawElementCallback = DrawExcludePathElement,
elementHeight = EditorConstants.FolderPathPickerHeight
};

_keywordReorderableList =new ReorderableList(
serializedObject,
serializedObject.FindProperty(KeywordsPropertyName))
Expand Down Expand Up @@ -103,6 +114,7 @@ public override void OnInspectorGUI()
EditorGUILayout.LabelField(EditorConstants.PackageContentHeader, EditorStyles.boldLabel);

_sourcePathsReorderableList.DoLayoutList();
_excludePathsReorderableList.DoLayoutList();

EditorGUILayout.BeginHorizontal();
var destinationPathProperty = serializedObject.FindProperty(DestinationPathPropertyName);
Expand Down Expand Up @@ -136,29 +148,42 @@ private void DrawSourcePathHeader(Rect rect)
}

private void DrawSourcePathElement(Rect rect, int index, bool isActive, bool isFocused)
{
DrawPathElement(SourcePathsPropertyName, rect, index, isActive, isFocused);
}

private void DrawExcludePathHeader(Rect rect)
{
EditorGUI.LabelField(rect, EditorConstants.IgnorePathsHeaderLabel, EditorStyles.boldLabel);
}

private void DrawExcludePathElement(Rect rect, int index, bool isActive, bool isFocused)
{
DrawPathElement(ExcludePathsPropertyName, rect, index, isActive, isFocused);
}

private void DrawPathElement(string propertyName, Rect rect, int index, bool isActive, bool isFocused)
{
rect.width -= EditorConstants.FolderPathPickerHeight * 2;
rect.height = EditorConstants.FolderPathPickerHeight;
var sourcePathRect = new Rect(rect);

var sourcePathProperty =
serializedObject.FindProperty(SourcePathsPropertyName).GetArrayElementAtIndex(index);
serializedObject.FindProperty(propertyName).GetArrayElementAtIndex(index);
EditorGUI.PropertyField(
sourcePathRect,
sourcePathProperty,
new GUIContent(string.Format(EditorConstants.SourcePathElementLabelFormat, index)));

var filePickerRect = new Rect
{
var filePickerRect = new Rect {
position = new Vector2(
sourcePathRect.width + EditorConstants.FolderPathPickerBuffer,
sourcePathRect.position.y),
width = EditorConstants.FolderPathPickerHeight,
height = EditorConstants.FolderPathPickerHeight,
};

var folderPickerRect = new Rect
{
var folderPickerRect = new Rect {
position = new Vector2(
sourcePathRect.width + EditorConstants.FolderPathPickerHeight + EditorConstants.FolderPathPickerBuffer,
sourcePathRect.position.y),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public string Id
/// </summary>
public string[] packageSourcePaths;

/// <summary>
/// A collection of file/folder paths to exclude from the package.
/// </summary>
public string[] packageIgnorePaths;

/// <summary>
/// A path to the package source distribution contents.
/// </summary>
Expand Down
20 changes: 19 additions & 1 deletion Unity/Assets/JCMG/PackageTools/Scripts/Editor/Tools/FileTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/
using System;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -138,6 +139,7 @@ public static void CreateOrUpdatePackageSource(PackageManifestConfig packageMani
else
{
RecursivelyCopyDirectoriesAndFiles(
packageManifest,
new DirectoryInfo(normalizedSourcePath),
normalizedSourcePath,
normalizedDestinationPath);
Expand Down Expand Up @@ -179,10 +181,12 @@ private static bool IsFile(string path)
/// Recursively copies all sub-folders and files in <see cref="DirectoryInfo"/> <paramref name="directoryInfo"/>
/// from parent folder <see cref="sourcePath"/> to <paramref name="destinationPath"/>.
/// </summary>
/// <param name="packageManifest"></param>
/// <param name="directoryInfo"></param>
/// <param name="sourcePath"></param>
/// <param name="destinationPath"></param>
private static void RecursivelyCopyDirectoriesAndFiles(
PackageManifestConfig packageManifest,
DirectoryInfo directoryInfo,
string sourcePath,
string destinationPath)
Expand All @@ -192,14 +196,28 @@ private static void RecursivelyCopyDirectoriesAndFiles(
var subDirectoryInfo = directoryInfo.GetDirectories(EditorConstants.WildcardFilter);
foreach (var sdi in subDirectoryInfo)
{
// If any of the paths we're looking at match the ignore paths from the user, skip them
if (packageManifest.packageIgnorePaths.Any(x =>
sdi.FullName.Contains(Path.GetFullPath(Path.Combine(EditorConstants.ProjectPath, x)))))
{
continue;
}

Directory.CreateDirectory(sdi.FullName.Replace(normalizedSourcePath, normalizedDestinationPath));

RecursivelyCopyDirectoriesAndFiles(sdi, normalizedSourcePath, normalizedDestinationPath);
RecursivelyCopyDirectoriesAndFiles(packageManifest, sdi, normalizedSourcePath, normalizedDestinationPath);
}

var fileInfo = directoryInfo.GetFiles(EditorConstants.WildcardFilter);
foreach (var fi in fileInfo)
{
// If any of the paths we're looking at match the ignore paths from the user, skip them
if (packageManifest.packageIgnorePaths.Any(x =>
fi.FullName.Contains(Path.GetFullPath(Path.Combine(EditorConstants.ProjectPath, x)))))
{
continue;
}

var newPath = Path.GetFullPath(fi.FullName).Replace(normalizedSourcePath, normalizedDestinationPath);
File.Copy(fi.FullName, newPath);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"com.jeffcampbellmakesgames.packagetools","displayName":"JCMG Package Tools","version":"1.0.1","unity":"2018.1","description":"Contains a set of Unity development tools to help support exporting and/or updating package contents. \n\nFor more information, see https://github.com/jeffcampbellmakesgames/unity-package-tools for more information.","keywords":["package","package manager"],"category":"Tools"}
{"name":"com.jeffcampbellmakesgames.packagetools","displayName":"JCMG Package Tools","version":"1.1.0","unity":"2018.1","description":"Contains a set of Unity development tools to help support exporting and/or updating package contents. \n\nFor more information, see https://github.com/jeffcampbellmakesgames/unity-package-tools for more information.","keywords":["package","package manager"],"category":"Tools"}
3 changes: 2 additions & 1 deletion Unity/Assets/PackageManifests/PackageManifestConfig.asset
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ MonoBehaviour:
m_EditorClassIdentifier:
packageSourcePaths:
- Assets/JCMG
packageIgnorePaths: []
packageDestinationPath: ../../unity-package-tools_release
packageName: com.jeffcampbellmakesgames.packagetools
displayName: JCMG Package Tools
packageVersion: 1.0.1
packageVersion: 1.1.0
unityVersion: 2018.1
description: Contains a set of Unity development tools to help support exporting
and/or updating package contents. \n\nFor more information, see https://github.com/jeffcampbellmakesgames/unity-package-tools
Expand Down
2 changes: 1 addition & 1 deletion Unity/Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"com.unity.package-manager-ui": "2.0.7",
"com.unity.package-manager-ui": "2.1.2",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
Expand Down
3 changes: 2 additions & 1 deletion Unity/ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
m_EditorVersion: 2018.3.11f1
m_EditorVersion: 2019.1.0f2
m_EditorVersionWithRevision: 2019.1.0f2 (292b93d75a2c)
10 changes: 10 additions & 0 deletions Unity/ProjectSettings/XRSettings.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"m_SettingKeys": [
"VR Device Disabled",
"VR Device User Alert"
],
"m_SettingValues": [
"False",
"False"
]
}

0 comments on commit 3cfb776

Please sign in to comment.