@@ -300,6 +300,66 @@ public static Process LaunchProject(Project proj, DataGrid dataGridRef = null, b
300300
301301 Console . WriteLine ( "Start process: " + cmd + " " + unitycommandlineparameters ) ;
302302
303+ // TODO load custom settings per project
304+ //string userSettingsFolder = Path.Combine(proj.Path, "UserSettings");
305+ //string userSettingsPath = Path.Combine(userSettingsFolder, "ULPSettings.txt");
306+ //if (File.Exists(userSettingsPath))
307+ //{
308+ // var rawSettings = File.ReadAllLines(userSettingsPath);
309+ // // needed for env vars.
310+ // newProcess.StartInfo.UseShellExecute = false;
311+ // foreach (var row in rawSettings)
312+ // {
313+ // var split = row.Split('=');
314+ // if (split.Length == 2)
315+ // {
316+ // var key = split[0].Trim();
317+ // var value = split[1].Trim();
318+ // if (string.IsNullOrEmpty(key) == false && string.IsNullOrEmpty(value) == false)
319+ // {
320+ // //Console.WriteLine("key: " + key + " value: " + value);
321+ // //newProcess.StartInfo.EnvironmentVariables[key] = value;
322+ // //System.Environment.SetEnvironmentVariable(key, value, EnvironmentVariableTarget.Machine);
323+ // var dict = newProcess.StartInfo.EnvironmentVariables;
324+ // // print all
325+ // foreach (System.Collections.DictionaryEntry de in dict)
326+ // {
327+ // Console.WriteLine(" {0} = {1}", de.Key, de.Value);
328+ // }
329+ // // check if key exists
330+ // if (dict.ContainsKey(key) == true)
331+ // {
332+ // // modify existing
333+ // //dict[key] = value;
334+ // newProcess.StartInfo.EnvironmentVariables.Remove(key);
335+ // newProcess.StartInfo.EnvironmentVariables.Add(key, value);
336+ // }
337+ // else
338+ // {
339+ // // add new
340+ // dict.Add(key, value);
341+ // }
342+ // //newProcess.StartInfo.EnvironmentVariables.
343+ // //if (newProcess.StartInfo.EnvironmentVariables.ContainsKey(key))
344+ // //{
345+ // // Console.WriteLine("exists: "+key);
346+ // // // Test Modify the existing environment variable
347+ // // newProcess.StartInfo.EnvironmentVariables[key] = "...";
348+ // // this works, maybe because its not a system variable?
349+ // //newProcess.StartInfo.EnvironmentVariables["TESTTEST"] = "...";
350+ // //}
351+ // //else
352+ // //{
353+ // // Console.WriteLine("add new: "+ value);
354+ // // // Optionally, add the environment variable if it does not exist
355+ // // newProcess.StartInfo.EnvironmentVariables.Add(key, value);
356+ // //}
357+ // Console.WriteLine("custom row: " + row + " key=" + key + " value:" + value);
358+ // }
359+ // }
360+ // }
361+ //}
362+
303363 newProcess . StartInfo . Arguments = unitycommandlineparameters ;
304364 newProcess . EnableRaisingEvents = true ;
305365 //newProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; // needed for unity 2023 for some reason? (otherwise console popups briefly), Cannot use this, whole Editor is invisible then
@@ -1990,8 +2050,45 @@ internal static void UninstallEditor(string path, string version)
19902050 Console . WriteLine ( "Removing desktop icon: " + unityIcon ) ;
19912051 File . Delete ( unityIcon ) ;
19922052 }
2053+ } // UninstallEditor
2054+
2055+ public static void DisplayProjectProperties ( Project proj , MainWindow owner )
2056+ {
2057+ var modalWindow = new ProjectProperties ( proj ) ;
2058+ modalWindow . ShowInTaskbar = owner == null ;
2059+ modalWindow . WindowStartupLocation = owner == null ? WindowStartupLocation . CenterScreen : WindowStartupLocation . CenterOwner ;
2060+ modalWindow . Topmost = owner == null ;
2061+ modalWindow . ShowActivated = true ;
2062+ modalWindow . Owner = owner ;
2063+ modalWindow . ShowDialog ( ) ;
2064+ var results = modalWindow . DialogResult . HasValue && modalWindow . DialogResult . Value ;
2065+
2066+ if ( results == true )
2067+ {
2068+ }
2069+ else
2070+ {
2071+ }
2072+ }
19932073
2074+ // TODO save custom env to proj settings?
2075+ internal static void SaveProjectSettings ( Project proj , string customEnvVars )
2076+ {
2077+ string userSettingsFolder = Path . Combine ( proj . Path , "UserSettings" ) ;
2078+
2079+ // save custom env file
2080+ if ( string . IsNullOrEmpty ( customEnvVars ) == false )
2081+ {
2082+ // check if UserSettings exists
19942083
2084+ if ( Directory . Exists ( userSettingsFolder ) == false ) Directory . CreateDirectory ( userSettingsFolder ) ;
2085+
2086+ // TODO think about settings format (other values will be added later)
2087+
2088+ string fullPath = Path . Combine ( userSettingsFolder , "ULPSettings.txt" ) ;
2089+ File . WriteAllText ( fullPath , customEnvVars ) ;
2090+ Console . WriteLine ( fullPath ) ;
2091+ }
19952092 }
19962093 } // class
19972094
0 commit comments