Skip to content

Commit

Permalink
Adjustments for Linux Unity editors
Browse files Browse the repository at this point in the history
  • Loading branch information
fundale committed Nov 3, 2024
1 parent 3e83cab commit cb93b1c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
#if UDONSHARP
using UdonSharpEditor;
#endif
using UnityEngine.SceneManagement;
using System.IO;
using System;
Expand Down Expand Up @@ -36,9 +38,13 @@ private static void CheckForLocalPanel()
// colorLabel.text = "Emission Color";
foreach (GameObject go in sceneObjects)
{
#if UDONSHARP
#pragma warning disable 0618 //suppressing obsoletion warnings
panel = go.GetUdonSharpComponent<VRSL_LocalUIControlPanel>();
#pragma warning restore 0618
#else
panel = go.GetComponent<VRSL_LocalUIControlPanel>();
#endif
if(panel != null)
{
hasLocalPanel = true;
Expand Down Expand Up @@ -78,13 +84,17 @@ public static void SavePatchData()
SerializedObject so = new SerializedObject(panel);
so.FindProperty("fixtureSaveFile").stringValue = AssetDatabase.GUIDFromAssetPath(path).ToString();
so.ApplyModifiedProperties();
#if UDONSHARP
#pragma warning disable 0618 //suppressing obsoletion warnings
panel.UpdateProxy();
#pragma warning restore 0618 //suppressing obsoletion warnings
panel.fixtureSaveFile = so.FindProperty("fixtureSaveFile").stringValue;
#pragma warning disable 0618 //suppressing obsoletion warnings
panel.ApplyProxyModifications();
#pragma warning restore 0618 //suppressing obsoletion warnings
#else
panel.fixtureSaveFile = so.FindProperty("fixtureSaveFile").stringValue;
#endif

/// asset = (VRSL_DMXPatchSettings) AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(panel.fixtureSaveFile), typeof(VRSL_DMXPatchSettings));
// asset.SetScene();
Expand Down Expand Up @@ -112,13 +122,17 @@ public static void SavePatchData()
SerializedObject so = new SerializedObject(panel);
so.FindProperty("fixtureSaveFile").stringValue = "NONE";
so.ApplyModifiedProperties();
#if UDONSHARP
#pragma warning disable 0618 //suppressing obsoletion warnings
panel.UpdateProxy();
#pragma warning restore 0618 //suppressing obsoletion warnings
panel.fixtureSaveFile = so.FindProperty("fixtureSaveFile").stringValue;
#pragma warning disable 0618 //suppressing obsoletion warnings
panel.ApplyProxyModifications();
#pragma warning restore 0618 //suppressing obsoletion warnings
#else
panel.fixtureSaveFile = so.FindProperty("fixtureSaveFile").stringValue;
#endif
SavePatchData();
}
catch(Exception e)
Expand Down Expand Up @@ -199,7 +213,7 @@ public static void ExportToMVR()
}
}

[MenuItem("VRSL/Export/To PDF", priority = 504)]
[MenuItem("VRSL/Export/To PDF (Windows)", priority = 504)]
public static void ExportToPDF()
{
CheckForLocalPanel();
Expand All @@ -208,8 +222,12 @@ public static void ExportToPDF()
{
try
{
#if !UNITY_EDITOR_LINUX
VRSL_DMXPatchSettings asset = (VRSL_DMXPatchSettings) AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(panel.fixtureSaveFile), typeof(VRSL_DMXPatchSettings));
asset.ToPDF();
#else
EditorUtility.DisplayDialog("PDF export error", "PDF export is currently a Windows only feature", "OK", "Cancel");
#endif
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
using System.Collections.Generic;
using System;
using System.Diagnostics;
using VRC.Udon;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEditor;
using UdonSharpEditor;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.Xml;
using System.Drawing.Printing;
using System.Drawing;
using System.Data;
using UnityEngine.UIElements;
using System.Linq;

#if UDONSHARP
using VRC.Udon;
using UdonSharpEditor;
#endif

#if !UNITY_EDITOR_LINUX
using System.Drawing.Printing;
#endif

namespace VRSL.EditorScripts
{
public class StringWriterUtf8 : StringWriter
Expand Down Expand Up @@ -256,9 +263,13 @@ public void SetDMXFixtureData()
List<VRStageLighting_DMX_Static> sceneFixtures = new List<VRStageLighting_DMX_Static>();
foreach(GameObject go in sceneObjects)
{
#if UDONSHARP
#pragma warning disable 0618 //suppressing obsoletion warnings
VRStageLighting_DMX_Static lightScript = go.GetUdonSharpComponent<VRStageLighting_DMX_Static>();
#pragma warning restore 0618 //suppressing obsoletion warnings
#else
VRStageLighting_DMX_Static lightScript = go.GetComponent<VRStageLighting_DMX_Static>();
#endif
if(lightScript != null)
{
sceneFixtures.Add(lightScript);
Expand Down Expand Up @@ -313,9 +324,13 @@ public void LoadDMXFixtureData()
List<VRStageLighting_DMX_Static> sceneFixtures = new List<VRStageLighting_DMX_Static>();
foreach(GameObject go in sceneObjects)
{
#if UDONSHARP
#pragma warning disable 0618 //suppressing obsoletion warnings
VRStageLighting_DMX_Static lightScript = go.GetUdonSharpComponent<VRStageLighting_DMX_Static>();
#pragma warning restore 0618 //suppressing obsoletion warnings
#else
VRStageLighting_DMX_Static lightScript = go.GetComponent<VRStageLighting_DMX_Static>();
#endif
if(lightScript != null)
{
sceneFixtures.Add(lightScript);
Expand Down Expand Up @@ -412,9 +427,11 @@ public void LoadDMXFixtureData()
}
sof.ApplyModifiedProperties();

#if UDONSHARP
#pragma warning disable 0618 //suppressing obsoletion warnings
fixture.UpdateProxy();
#pragma warning restore 0618 //suppressing obsoletion warnings.
#endif

fixture.enableDMXChannels = data[dmxID].enableDMXChannels;
fixture.fixtureID = data[dmxID].fixtureID;
Expand Down Expand Up @@ -445,9 +462,11 @@ public void LoadDMXFixtureData()
fixture.fixtureDefintion = data[dmxID].fixtureDefintion;
fixture.objRenderers = rends;

#if UDONSHARP
#pragma warning disable 0618 //suppressing obsoletion warnings
fixture.ApplyProxyModifications();
#pragma warning restore 0618 //suppressing obsoletion warnings
#endif
if(PrefabUtility.IsPartOfAnyPrefab(fixture))
{
PrefabUtility.RecordPrefabInstancePropertyModifications(fixture);
Expand Down Expand Up @@ -485,9 +504,13 @@ private bool CheckForLocalPanel()
// colorLabel.text = "Emission Color";
foreach (GameObject go in sceneObjects)
{
#if UDONSHARP
#pragma warning disable 0618 //suppressing obsoletion warnings
panel = go.GetUdonSharpComponent<VRSL_LocalUIControlPanel>();
#pragma warning restore 0618
#else
panel = go.GetComponent<VRSL_LocalUIControlPanel>();
#endif
if(panel != null)
{
hasLocalPanel = true;
Expand All @@ -496,6 +519,7 @@ private bool CheckForLocalPanel()
}
return hasLocalPanel;
}
#if !UNITY_EDITOR_LINUX
private void OnPrintPage(object sender, PrintPageEventArgs ev)
{
pdfPageCount++;
Expand Down Expand Up @@ -693,6 +717,7 @@ public void ToPDF()
document.Print();
UnityEngine.Debug.Log("Sucessfully Exported PDF File");
}
#endif
public string ToJsonFile(bool refreshEditor)
{
if(CheckForLocalPanel())
Expand Down Expand Up @@ -1630,9 +1655,13 @@ public override void OnInspectorGUI()
{
settings.ToMVRFile();
}
if(GUILayout.Button("Export To PDF File"))
if(GUILayout.Button("Export To PDF File (Windows)"))
{
#if !UNITY_EDITOR_LINUX
settings.ToPDF();
#else
EditorUtility.DisplayDialog("PDF export error", "PDF export is currently a Windows only feature", "OK", "Cancel");
#endif
}
if(settings.data != null)
{
Expand Down

0 comments on commit cb93b1c

Please sign in to comment.