Skip to content

Commit cc97aab

Browse files
committed
handle multiple Unity projects open
when bringing to front. Check that we are bringing the window with the correct open project to the front
1 parent 34a49c8 commit cc97aab

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Executable + Temp files ##
22
*.exe
33
*.exe.*
4+
!BringToFront.exe
45
*.o
56
*.pdb
67
*.mdb

Assets/Integrations/Autodesk/maya/scripts/unityOneClick/commands.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,10 @@ def doIt(self, args):
306306
.format(unityAppPath, unityProjectPath, unityCommand)
307307

308308
elif maya.cmds.about(windows=True):
309-
melCommand = r'system("start \"{0}\" \"{1}\" \"-projectPath {2} -executeMethod {3}\"");'\
310-
.format(unityProjectPath + "/Assets/Integrations/BringToFront.exe", unityAppPath, unityProjectPath, unityCommand)
309+
melCommand = r'system("start \"{0}\" \"{1}\" \"{2}\" \"-projectPath {3} -executeMethod {4}\"");'\
310+
.format(unityProjectPath + "/Assets/Integrations/BringToFront.exe",
311+
os.path.basename(unityProjectPath), unityAppPath,
312+
unityProjectPath, unityCommand)
311313

312314
else:
313315
raise NotImplementedError("missing platform implementation for {0}".format(maya.cmds.about(os=True)))

Assets/Integrations/BringToFront.exe

4.5 KB
Binary file not shown.

BringToFront.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,20 @@ static void Main(string[] args)
4747
{
4848
if (!String.IsNullOrEmpty(process.MainWindowTitle))
4949
{
50+
if(args.Length > 0 && !process.MainWindowTitle.Contains(args[0]))
51+
{
52+
continue;
53+
}
5054
bringToFront(process.MainWindowTitle);
5155
found = true;
5256
}
5357
}
5458

55-
if(!found){
59+
if(!found && args.Length > 1){
5660
Process myProcess = new Process();
57-
myProcess.StartInfo.FileName = args[0];
58-
if(args.Length > 1){
59-
myProcess.StartInfo.Arguments = args[1];
61+
myProcess.StartInfo.FileName = args[1];
62+
if(args.Length > 2){
63+
myProcess.StartInfo.Arguments = args[2];
6064
}
6165
myProcess.Start();
6266
}

0 commit comments

Comments
 (0)