-
Notifications
You must be signed in to change notification settings - Fork 8
Added Unity 6 Support #6
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
6a4f489
075cae7
85e6135
c16eb0d
757169a
aeb8397
9ce229d
535dd80
392be3e
db1fe7c
84dbcd2
7482af1
9a15761
6a5a9d9
2f65ba3
7d5fade
4a23ae7
2556234
742a604
cb2344c
87e6f14
bedda16
0fe3d75
f5d3732
bd981fa
92676cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,9 +14,18 @@ public override float GetPropertyHeight (SerializedProperty property, GUIContent | |||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| // Support dark/light mode for label text | ||||||||||||||||||||||||||||||||||||
| Color originalLabelColor = GUI.color; | ||||||||||||||||||||||||||||||||||||
| if (!EditorGUIUtility.isProSkin) | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| GUI.color = new Color(0, 0, 0, 1); // Black for light mode | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| SerializedProperty colorProp = property.FindPropertyRelative("color"); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); | ||||||||||||||||||||||||||||||||||||
| EditorGUI.PropertyField(singleFieldRect, colorProp); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| GUI.color = originalLabelColor; | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+17
to
+29
|
||||||||||||||||||||||||||||||||||||
| // Support dark/light mode for label text | |
| Color originalLabelColor = GUI.color; | |
| if (!EditorGUIUtility.isProSkin) | |
| { | |
| GUI.color = new Color(0, 0, 0, 1); // Black for light mode | |
| } | |
| SerializedProperty colorProp = property.FindPropertyRelative("color"); | |
| Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); | |
| EditorGUI.PropertyField(singleFieldRect, colorProp); | |
| GUI.color = originalLabelColor; | |
| SerializedProperty colorProp = property.FindPropertyRelative("color"); | |
| Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); | |
| EditorGUI.PropertyField(singleFieldRect, colorProp); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,13 @@ public override float GetPropertyHeight (SerializedProperty property, GUIContent | |
|
|
||
| public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) | ||
| { | ||
| // Support dark/light mode for label text | ||
| Color originalLabelColor = GUI.color; | ||
| if (!EditorGUIUtility.isProSkin) | ||
| { | ||
| GUI.color = new Color(0, 0, 0, 1); // Black for light mode | ||
| } | ||
|
Comment on lines
+18
to
+22
|
||
|
|
||
| SerializedProperty colorProp = property.FindPropertyRelative("color"); | ||
| SerializedProperty fontSizeProp = property.FindPropertyRelative("fontSize"); | ||
| SerializedProperty textProp = property.FindPropertyRelative("text"); | ||
|
|
@@ -26,5 +33,7 @@ public override void OnGUI (Rect position, SerializedProperty property, GUIConte | |
|
|
||
| singleFieldRect.y += EditorGUIUtility.singleLineHeight; | ||
| EditorGUI.PropertyField(singleFieldRect, textProp); | ||
|
|
||
| GUI.color = originalLabelColor; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,9 +12,18 @@ public override float GetPropertyHeight (SerializedProperty property, GUIContent | |||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| // Support dark/light mode for label text | ||||||||||||||||||||||||||||||||||||
| Color originalLabelColor = GUI.color; | ||||||||||||||||||||||||||||||||||||
| if (!EditorGUIUtility.isProSkin) | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| GUI.color = new Color(0, 0, 0, 1); // Black for light mode | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| SerializedProperty timeScaleProp = property.FindPropertyRelative("timeScale"); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); | ||||||||||||||||||||||||||||||||||||
| EditorGUI.PropertyField(singleFieldRect, timeScaleProp); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| GUI.color = originalLabelColor; | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+27
|
||||||||||||||||||||||||||||||||||||
| // Support dark/light mode for label text | |
| Color originalLabelColor = GUI.color; | |
| if (!EditorGUIUtility.isProSkin) | |
| { | |
| GUI.color = new Color(0, 0, 0, 1); // Black for light mode | |
| } | |
| SerializedProperty timeScaleProp = property.FindPropertyRelative("timeScale"); | |
| Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); | |
| EditorGUI.PropertyField(singleFieldRect, timeScaleProp); | |
| GUI.color = originalLabelColor; | |
| SerializedProperty timeScaleProp = property.FindPropertyRelative("timeScale"); | |
| Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); | |
| EditorGUI.PropertyField(singleFieldRect, timeScaleProp); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,13 @@ public override float GetPropertyHeight (SerializedProperty property, GUIContent | |
|
|
||
| public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) | ||
| { | ||
| // Support dark/light mode for label text | ||
| Color originalLabelColor = GUI.color; | ||
| if (!EditorGUIUtility.isProSkin) | ||
| { | ||
| GUI.color = new Color(0, 0, 0, 1); // Black for light mode | ||
| } | ||
|
Comment on lines
+24
to
+28
|
||
|
|
||
| SerializedProperty tweenPositionProp = property.FindPropertyRelative ("tweenPosition"); | ||
| SerializedProperty tweenRotationProp = property.FindPropertyRelative("tweenRotation"); | ||
| SerializedProperty tweenTypeProp = property.FindPropertyRelative ("tweenType"); | ||
|
|
@@ -40,5 +47,7 @@ public override void OnGUI (Rect position, SerializedProperty property, GUIConte | |
| singleFieldRect.y += EditorGUIUtility.singleLineHeight; | ||
| EditorGUI.PropertyField (singleFieldRect, customCurveProp, m_CustomCurveContent); | ||
| } | ||
|
|
||
| GUI.color = originalLabelColor; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,12 @@ public override void OnInspectorGUI() | |||||||||||
| { | ||||||||||||
| VideoScriptPlayableAsset videoAsset = (VideoScriptPlayableAsset)target; | ||||||||||||
| GUIStyle lStyle = GetLabelStyle(); | ||||||||||||
|
|
||||||||||||
| // Ensure label color is set for dark/light mode compatibility | ||||||||||||
| if (lStyle.normal.textColor == Color.black) | ||||||||||||
| { | ||||||||||||
| lStyle.normal.textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+27
to
32
|
||||||||||||
| // Ensure label color is set for dark/light mode compatibility | |
| if (lStyle.normal.textColor == Color.black) | |
| { | |
| lStyle.normal.textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black; | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,8 +17,20 @@ static GameViewUtils() | |||||||||||||||
| gameViewSizesInstance = instanceProp.GetValue(null, null); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /// <summary> | ||||||||||||||||
| /// Ensures the value is even (required for MP4/H.264 encoding) | ||||||||||||||||
| /// </summary> | ||||||||||||||||
| private static int MakeEven(int value) | ||||||||||||||||
| { | ||||||||||||||||
| return (value % 2 == 0) ? value : value + 1; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| public static void AddSetSize(int width, int height) | ||||||||||||||||
| { | ||||||||||||||||
| // MP4 format requires even dimensions for H.264 codec | ||||||||||||||||
| width = MakeEven(width); | ||||||||||||||||
| height = MakeEven(height); | ||||||||||||||||
|
|
||||||||||||||||
| int idx = FindSize(GameViewSizeGroupType.Standalone, width, height); | ||||||||||||||||
| if (idx == -1) | ||||||||||||||||
| { | ||||||||||||||||
|
|
@@ -58,25 +70,24 @@ public static void AddCustomSize(GameViewSizeType viewSizeType, GameViewSizeGrou | |||||||||||||||
| var group = GetGroup(sizeGroupType); | ||||||||||||||||
| var addCustomSize = getGroup.ReturnType.GetMethod("AddCustomSize"); // or group.GetType(). | ||||||||||||||||
| var gvsType = typeof(Editor).Assembly.GetType("UnityEditor.GameViewSize"); | ||||||||||||||||
| #if NET_4_6 | ||||||||||||||||
| var ctor = gvsType.GetConstructor(new Type[] { typeof(Editor).Assembly.GetType("UnityEditor.GameViewSizeType"), typeof(int), typeof(int), typeof(string) }); | ||||||||||||||||
| var newGvsType = typeof(Editor).Assembly.GetType("UnityEditor.GameViewSizeType"); | ||||||||||||||||
| if (viewSizeType == GameViewSizeType.AspectRatio) | ||||||||||||||||
|
|
||||||||||||||||
| // Unity 6 and modern Unity versions use the constructor with GameViewSizeType enum | ||||||||||||||||
| var gvsTypeEnum = typeof(Editor).Assembly.GetType("UnityEditor.GameViewSizeType"); | ||||||||||||||||
| var ctor = gvsType.GetConstructor(new Type[] { gvsTypeEnum, typeof(int), typeof(int), typeof(string) }); | ||||||||||||||||
|
|
||||||||||||||||
| if (ctor != null) | ||||||||||||||||
| { | ||||||||||||||||
| newGvsType = typeof(Editor).Assembly.GetType("UnityEditor.GameViewSizeType.AspectRatio"); | ||||||||||||||||
| // Modern Unity version with enum parameter | ||||||||||||||||
| var newSize = ctor.Invoke(new object[] { (int)viewSizeType, width, height, text }); | ||||||||||||||||
| addCustomSize.Invoke(group, new object[] { newSize }); | ||||||||||||||||
| } | ||||||||||||||||
| else | ||||||||||||||||
| { | ||||||||||||||||
| newGvsType = typeof(Editor).Assembly.GetType("UnityEditor.GameViewSizeType.FixedResolution"); | ||||||||||||||||
| // Fallback for older Unity versions with int parameter | ||||||||||||||||
| ctor = gvsType.GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int), typeof(string) }); | ||||||||||||||||
|
||||||||||||||||
| ctor = gvsType.GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int), typeof(string) }); | |
| ctor = gvsType.GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int), typeof(string) }); | |
| if (ctor == null) | |
| { | |
| Debug.LogError("GameViewUtils.AddCustomSize: Unable to find a suitable UnityEditor.GameViewSize constructor for this Unity version."); | |
| return; | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,11 +38,11 @@ public static void Init() | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public void OnGUI() | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| scrollPos = GUILayout.BeginScrollView(scrollPos); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| GUIStyle hStyle = GetHeadingStyle(); | ||||||||||||||||||||||||
| GUIStyle pStyle = GetParagraphStyle(); | ||||||||||||||||||||||||
| GUIStyle bStyle = GetButtonStyle(); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| scrollPos = GUILayout.BeginScrollView(scrollPos); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| GUILayout.Label("Unity Video Editor Template", hStyle); | ||||||||||||||||||||||||
| GUILayout.Label("Thank you for downloading the Video Editor Template.", pStyle); | ||||||||||||||||||||||||
|
|
@@ -65,9 +65,26 @@ public void OnGUI() | |||||||||||||||||||||||
| GUILayout.EndVertical(); | ||||||||||||||||||||||||
| if (GUILayout.Button("Set Resolution", SetResButtonStyle(), GUILayout.Height(42))) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| // MP4 format requires even dimensions | ||||||||||||||||||||||||
| int adjustedWidth = (width % 2 == 0) ? width : width + 1; | ||||||||||||||||||||||||
| int adjustedHeight = (height % 2 == 0) ? height : height + 1; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (adjustedWidth != width || adjustedHeight != height) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| width = adjustedWidth; | ||||||||||||||||||||||||
| height = adjustedHeight; | ||||||||||||||||||||||||
| UnityEngine.Debug.LogWarning($"Resolution adjusted to even dimensions for MP4 compatibility: {width}x{height}"); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+68
to
+78
|
||||||||||||||||||||||||
| // MP4 format requires even dimensions | |
| int adjustedWidth = (width % 2 == 0) ? width : width + 1; | |
| int adjustedHeight = (height % 2 == 0) ? height : height + 1; | |
| if (adjustedWidth != width || adjustedHeight != height) | |
| { | |
| width = adjustedWidth; | |
| height = adjustedHeight; | |
| UnityEngine.Debug.LogWarning($"Resolution adjusted to even dimensions for MP4 compatibility: {width}x{height}"); | |
| } | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using GUI.color to control label text color is incorrect. GUI.color is a tint that affects all GUI elements including backgrounds, borders, and textures. For controlling text color specifically in PropertyDrawers, you should use the GUIStyle.normal.textColor property or leave the default styling which Unity handles automatically. This implementation may cause unintended visual effects on other GUI elements.