Skip to content

Commit

Permalink
Merge pull request #44 from VeriorPies/Develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
314pies authored Apr 29, 2021
2 parents c792f57 + 6dde1a9 commit 95a062c
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 41 deletions.
1 change: 1 addition & 0 deletions Images/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.meta
5 changes: 1 addition & 4 deletions ParrelSync/Editor/AssetModBlock/EditorQuit.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor;
namespace ParrelSync
{
[InitializeOnLoad]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor;
using UnityEngine;
namespace ParrelSync
{
Expand Down
19 changes: 13 additions & 6 deletions ParrelSync/Editor/ClonesManager.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using UnityEditor;
using System.Linq;
using System.Runtime.InteropServices;
using System.IO;
using Debug = UnityEngine.Debug;

Expand Down Expand Up @@ -101,11 +99,19 @@ public static Project CreateCloneFromPath(string sourceProjectPath)
Debug.Log("Start cloning project, original project: " + sourceProject + ", clone project: " + cloneProject);

ClonesManager.CreateProjectFolder(cloneProject);
ClonesManager.CopyLibraryFolder(sourceProject, cloneProject);

//Copy Folders
Debug.Log("Library copy: " + cloneProject.libraryPath);
ClonesManager.CopyDirectoryWithProgressBar(sourceProject.libraryPath, cloneProject.libraryPath,
"Cloning Project Library '" + sourceProject.name + "'. ");
Debug.Log("Packages copy: " + cloneProject.libraryPath);
ClonesManager.CopyDirectoryWithProgressBar(sourceProject.packagesPath, cloneProject.packagesPath,
"Cloning Project Packages '" + sourceProject.name + "'. ");


//Link Folders
ClonesManager.LinkFolders(sourceProject.assetPath, cloneProject.assetPath);
ClonesManager.LinkFolders(sourceProject.projectSettingsPath, cloneProject.projectSettingsPath);
ClonesManager.LinkFolders(sourceProject.packagesPath, cloneProject.packagesPath);
ClonesManager.LinkFolders(sourceProject.autoBuildPath, cloneProject.autoBuildPath);
ClonesManager.LinkFolders(sourceProject.localPackages, cloneProject.localPackages);

Expand Down Expand Up @@ -280,6 +286,7 @@ public static void CreateProjectFolder(Project project)
/// </summary>
/// <param name="sourceProject"></param>
/// <param name="destinationProject"></param>
[System.Obsolete]
public static void CopyLibraryFolder(Project sourceProject, Project destinationProject)
{
if (Directory.Exists(destinationProject.libraryPath))
Expand Down Expand Up @@ -322,7 +329,7 @@ private static void CreateLinkLinux(string sourcePath, string destinationPath)
{
sourcePath = sourcePath.Replace(" ", "\\ ");
destinationPath = destinationPath.Replace(" ", "\\ ");
var command = $"ln -s {sourcePath} {destinationPath}";
var command = string.Format("ln -s {0} {1}", sourcePath, destinationPath);

Debug.Log("Linux Symlink " + command);

Expand Down
4 changes: 1 addition & 3 deletions ParrelSync/Editor/ClonesManagerWindow.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEditor;
using System.IO;

Expand Down
5 changes: 1 addition & 4 deletions ParrelSync/Editor/ExternalLinks.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace ParrelSync
namespace ParrelSync
{
public class ExternalLinks
{
Expand Down
4 changes: 1 addition & 3 deletions ParrelSync/Editor/FileUtilities.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.IO;
using UnityEngine;

namespace ParrelSync
Expand Down
2 changes: 0 additions & 2 deletions ParrelSync/Editor/NonCore/AskFeedbackDialog.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
namespace ParrelSync.NonCore
{
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

Expand Down
2 changes: 0 additions & 2 deletions ParrelSync/Editor/NonCore/OtherMenuItem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
namespace ParrelSync.NonCore
{
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

Expand Down
4 changes: 1 addition & 3 deletions ParrelSync/Editor/Preferences.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEditor;

namespace ParrelSync
Expand Down
4 changes: 1 addition & 3 deletions ParrelSync/Editor/Project.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections.Generic;
using System.Linq;

namespace ParrelSync
Expand Down
4 changes: 1 addition & 3 deletions ParrelSync/Editor/UpdateChecker.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace ParrelSync.Update
Expand All @@ -11,7 +9,7 @@ namespace ParrelSync.Update
public class UpdateChecker
{
//const string LocalVersionFilePath = "Assets/ParrelSync/VERSION.txt";
public const string LocalVersion = "1.4.2";
public const string LocalVersion = "1.5.0";
[MenuItem("ParrelSync/Check for update", priority = 20)]
static void CheckForUpdate()
{
Expand Down
73 changes: 73 additions & 0 deletions ParrelSync/Editor/ValidateCopiedFoldersIntegrity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
namespace ParrelSync.NonCore
{
using UnityEditor;
using UnityEngine;
using System;
using System.Text;
using System.Security.Cryptography;
using System.IO;
using System.Linq;

[InitializeOnLoad]
public class ValidateCopiedFoldersIntegrity
{
const string SessionStateKey = "ValidateCopiedFoldersIntegrity_Init";
/// <summary>
/// Called once on editor startup.
/// Validate copied folders integrity in clone project
/// </summary>
static ValidateCopiedFoldersIntegrity()
{
if (!SessionState.GetBool(SessionStateKey, false))
{
SessionState.SetBool(SessionStateKey, true);
if (!ClonesManager.IsClone()) { return; }

ValidateFolder("Packages");
}
}

static void ValidateFolder(string folderName)
{
var currentProjectPath = Path.Combine(ClonesManager.GetCurrentProjectPath(), folderName);
var currentFolderHash = CreateMd5ForFolder(currentProjectPath);

var originalProjectPath = Path.Combine(ClonesManager.GetOriginalProjectPath(), folderName);
var originalFolderHash = CreateMd5ForFolder(originalProjectPath);

if (currentFolderHash != originalFolderHash)
{
Debug.Log("ParrelSync: Detected '" + folderName + "' folder changes in the original project. Updating...");
FileUtil.ReplaceDirectory(originalProjectPath, currentProjectPath);
}
}

static string CreateMd5ForFolder(string path)
{
// assuming you want to include nested folders
var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)
.OrderBy(p => p).ToList();

MD5 md5 = MD5.Create();

for (int i = 0; i < files.Count; i++)
{
string file = files[i];

// hash path
string relativePath = file.Substring(path.Length + 1);
byte[] pathBytes = Encoding.UTF8.GetBytes(relativePath.ToLower());
md5.TransformBlock(pathBytes, 0, pathBytes.Length, pathBytes, 0);

// hash contents
byte[] contentBytes = File.ReadAllBytes(file);
if (i == files.Count - 1)
md5.TransformFinalBlock(contentBytes, 0, contentBytes.Length);
else
md5.TransformBlock(contentBytes, 0, contentBytes.Length, contentBytes, 0);
}

return BitConverter.ToString(md5.Hash).Replace("-", "").ToLower();
}
}
}
11 changes: 11 additions & 0 deletions ParrelSync/Editor/ValidateCopiedFoldersIntegrity.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ParrelSync/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.veriorpies.parrelsync",
"displayName": "ParrelSync",
"version": "1.4.2",
"version": "1.5.0",
"unity": "2018.4",
"description": "ParrelSync is a Unity editor extension that allows users to test multiplayer gameplay without building the project by having another Unity editor window opened and mirror the changes from the original project.",
"license": "MIT",
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ to the `Packages/manifest.json` file


## Supported Platform
Currently, ParrelSync supports Windows and macOS editors.
For Linux support, please download the [latest 1.4.2 beta release](https://github.com/VeriorPies/ParrelSync/releases/tag/1.4.2).
Currently, ParrelSync supports Windows, macOS and Linux editors.

ParrelSync has been tested with the following Unity version. However, it should also work with other versions as well.
* *2020.1.2f1*
* *2020.3.1f1*
* *2019.3.0f6*
* *2018.4.22f1*

Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.2
1.5.0

0 comments on commit 95a062c

Please sign in to comment.