Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Linux Editor #22

Merged
merged 21 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Images/UPM_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/UPM_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 36 additions & 13 deletions ParrelSync/Editor/ClonesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static Project CreateCloneFromPath(string sourceProjectPath)
ClonesManager.LinkFolders(sourceProject.packagesPath, cloneProject.packagesPath);
ClonesManager.LinkFolders(sourceProject.autoBuildPath, cloneProject.autoBuildPath);
ClonesManager.LinkFolders(sourceProject.localPackages, cloneProject.localPackages);

ClonesManager.RegisterClone(cloneProject);

return cloneProject;
Expand Down Expand Up @@ -165,6 +165,8 @@ private static string GetApplicationPath()
return EditorApplication.applicationPath;
case RuntimePlatform.OSXEditor:
return EditorApplication.applicationPath + "/Contents/MacOS/Unity";
case RuntimePlatform.LinuxEditor:
return EditorApplication.applicationPath;
default:
throw new System.NotImplementedException("Platform has not supported yet ;(");
}
Expand All @@ -190,12 +192,12 @@ public static bool IsCloneProjectRunning(string projectPath)
if (Preferences.AlsoCheckUnityLockFileStaPref.Value)
return File.Exists(UnityLockFilePath) && FileUtilities.IsFileLocked(UnityLockFilePath);
else
return File.Exists(UnityLockFilePath);
return File.Exists(UnityLockFilePath);
case (RuntimePlatform.OSXEditor):
//Mac editor won't lock "UnityLockfile" file when project is being opened
return File.Exists(UnityLockFilePath);
case (RuntimePlatform.LinuxEditor):
throw new System.NotImplementedException("IsCloneProjectRunning: No linux implementation yet.");
return File.Exists(UnityLockFilePath);
default:
throw new System.NotImplementedException("IsCloneProjectRunning: Unsupport Platfrom: " + Application.platform);
}
Expand Down Expand Up @@ -244,8 +246,13 @@ public static void DeleteClone(string cloneProjectPath)

break;
case (RuntimePlatform.LinuxEditor):
throw new System.NotImplementedException("No linux support yet :(");
//break;
Debug.Log("Attempting to delete folder \"" + cloneProjectPath + "\"");
identifierFile = Path.Combine(cloneProjectPath, ClonesManager.ArgumentFileName);
File.Delete(identifierFile);

FileUtil.DeleteFileOrDirectory(cloneProjectPath);

break;
default:
Debug.LogWarning("Not in a known editor. Where are you!?");
break;
Expand Down Expand Up @@ -305,6 +312,22 @@ private static void CreateLinkMac(string sourcePath, string destinationPath)
ClonesManager.ExecuteBashCommand(command);
}

/// <summary>
/// Creates a symlink between destinationPath and sourcePath (Linux version).
/// </summary>
/// <param name="sourcePath"></param>
/// <param name="destinationPath"></param>
private static void CreateLinkLinux(string sourcePath, string destinationPath)
{
sourcePath = sourcePath.Replace(" ", "\\ ");
destinationPath = destinationPath.Replace(" ", "\\ ");
var command = $"ln -s {sourcePath} {destinationPath}";

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

ClonesManager.ExecuteBashCommand(command);
}

/// <summary>
/// Creates a symlink between destinationPath and sourcePath (Windows version).
/// </summary>
Expand Down Expand Up @@ -343,8 +366,8 @@ public static void LinkFolders(string sourcePath, string destinationPath)
CreateLinkMac(sourcePath, destinationPath);
break;
case (RuntimePlatform.LinuxEditor):
throw new System.NotImplementedException("LinkFolders: No linux support yet.");
//break;
CreateLinkLinux(sourcePath, destinationPath);
break;
default:
Debug.LogWarning("Not in a known editor. Application.platform: " + Application.platform);
break;
Expand Down Expand Up @@ -375,7 +398,7 @@ public static bool IsClone()
isCloneFileExistCache = File.Exists(cloneFilePath);
}

return (bool) isCloneFileExistCache;
return (bool)isCloneFileExistCache;
}

/// <summary>
Expand Down Expand Up @@ -534,7 +557,7 @@ private static void CopyDirectoryWithProgressBarRecursive(DirectoryInfo source,
copiedBytes += file.Length;

/// Display the progress bar.
float progress = (float) copiedBytes / (float) totalBytes;
float progress = (float)copiedBytes / (float)totalBytes;
bool cancelCopy = EditorUtility.DisplayCancelableProgressBar(
progressBarPrefix + "Copying '" + source.FullName + "' to '" + destination.FullName + "'...",
"(" + (progress * 100f).ToString("F2") + "%) Copying file '" + file.Name + "'...",
Expand Down Expand Up @@ -623,11 +646,11 @@ private static void ExecuteBashCommand(string command)
}
}
}

public static void OpenProjectInFileExplorer(string path)
{
System.Diagnostics.Process.Start(@path);
{
System.Diagnostics.Process.Start(@path);
}
#endregion
}
}
}
13 changes: 0 additions & 13 deletions ParrelSync/Editor/ClonesManagerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,6 @@ private static void InitWindow()

private void OnGUI()
{
if (Application.platform == RuntimePlatform.LinuxEditor)
{
EditorGUILayout.HelpBox(
"Sorry, but " + ClonesManager.ProjectName + " doesn't support Linux currently.\n" +
"Please create a feature request on GitHub issue page if you want it to be added.",
MessageType.Info);
if (GUILayout.Button("Open GitHub issue Page"))
{
Application.OpenURL(ExternalLinks.GitHubIssue);
}
return;
}

/// If it is a clone project...
if (ClonesManager.IsClone())
{
Expand Down
14 changes: 9 additions & 5 deletions ParrelSync/Editor/UpdateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ namespace ParrelSync.Update
/// </summary>
public class UpdateChecker
{
const string LocalVersionFilePath = "Assets/ParrelSync/VERSION.txt";
//const string LocalVersionFilePath = "Assets/ParrelSync/VERSION.txt";
public const string LocalVersion = "1.4.1";
[MenuItem("ParrelSync/Check for update", priority = 20)]
static void CheckForUpdate()
{
using (System.Net.WebClient client = new System.Net.WebClient())
{
try
{
string localVersionText = AssetDatabase.LoadAssetAtPath<TextAsset>(LocalVersionFilePath).text;
Debug.Log("Local version text : " + localVersionText);
//This won't work with UPM packages
//string localVersionText = AssetDatabase.LoadAssetAtPath<TextAsset>(LocalVersionFilePath).text;

string localVersionText = LocalVersion;
Debug.Log("Local version text : " + LocalVersion);

string latesteVersionText = client.DownloadString(ExternalLinks.RemoteVersionURL);
Debug.Log("latest version text got: " + latesteVersionText);
Expand Down Expand Up @@ -48,11 +52,11 @@ static void CheckForUpdate()
catch (Exception exp)
{
Debug.LogError("Error with checking update. Exception: " + exp);
EditorUtility.DisplayDialog("Update Error","Error with checking update. \nSee console fore more details.",
EditorUtility.DisplayDialog("Update Error","Error with checking update. \nSee console for more details.",
"OK"
);
}
}
}
}
}
}
10 changes: 10 additions & 0 deletions ParrelSync/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "com.veriorpies.parrelsync",
"displayName": "ParrelSync",
"version": "1.4.1",
"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",
"keywords": [ "Networking", "Utils", "Editor", "Extensions" ],
"dependencies": {}
}
7 changes: 7 additions & 0 deletions ParrelSync/package.json.meta

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

26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,37 @@ ParrelSync is a Unity editor extension that allows users to test multiplayer gam
3. Protected assets from being modified by other clone instances
4. Handy APIs to speed up testing workflows
## Installation

1. Backup your project folder or use a version control system such as [Git](https://git-scm.com/) or [SVN](https://subversion.apache.org/)
2. Download .unitypackage from the [latest release](https://github.com/VeriorPies/ParrelSync/releases) and import it to your project.
3. Parrel Sync should appreared in the menu item bar after imported
3. ParrelSync should appreared in the menu item bar after imported
![UpdateButtonInMenu](https://github.com/VeriorPies/ParrelSync/raw/master/Images/AfterImported.png)

Check out the [Installation-and-Update](https://github.com/VeriorPies/ParrelSync/wiki/Installation-and-Update) page for more details.

### UPM Package
ParrelSync can also be installed via UPM package.
After Unity 2019.3.4f1, Unity 2020.1a21, which support path query parameter of git package. You can install ParrelSync by adding the following to Package Manager.

```
https://github.com/VeriorPies/ParrelSync.git?path=/ParrelSync
```


![UPM_Image](https://github.com/VeriorPies/ParrelSync/raw/master/Images/UPM_1.png?raw=true) ![UPM_Image2](https://github.com/VeriorPies/ParrelSync/raw/master/Images/UPM_2.png?raw=true)

or by adding

```
"com.veriorpies.parrelsync": "https://github.com/VeriorPies/ParrelSync.git?path=/ParrelSync"
```

to the `Packages/manifest.json` file


## Supported Platform
Currently, ParrelSync supports Windows and macOS editors.
Please create a [feature request](https://github.com/VeriorPies/ParrelSync/issues/new/choose) if you want Linux support to be added.
Currently, ParrelSync supports Windows, macOS and Linux editors.
Please create a [feature request](https://github.com/VeriorPies/ParrelSync/issues/new/choose) if you want support to be added.

ParrelSync has been tested with the following Unity version. However, it should also work with other versions as well.
* *2020.1.2f1*
Expand Down