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

Update Awaitable.Threading.cs #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 14 additions & 5 deletions Editor/Mono/AssetPipeline/SpeedTree/SpeedTree9Importer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@

namespace UnityEditor.SpeedTree.Importer
{
// [2024-08-07] version: 2
// Fixed mesh's UV2 & UV3 data usage strategy to 'always allocate' from 'conditionally allocate'
// to fix unwanted application of leaf-facing effect to geometries without leaf-facing data.

[ScriptedImporter(version: 2, ext: "st9", AllowCaching = true)]
// [2024-09-27] version: 3
// Fixed code that would lead to m_LODCount vs m_PerLODSettings.arraySize mismatching in GUI
[ScriptedImporter(version: 3, ext: "st9", AllowCaching = true)]
public class SpeedTree9Importer : ScriptedImporter
{
const int SPEEDTREE_9_WIND_VERSION = 1;
Expand Down Expand Up @@ -233,6 +231,16 @@ private void CacheTreeImporterValues(string assetPath)
{
// Variables used a lot are cached, since accessing any Reader array has a non-negligeable cost.
m_LODCount = (uint)m_Tree.Lod.Length;
if(m_LODCount > LODGroupGUI.kLODColors.Length)
{
Debug.LogWarningFormat("Number of LOD meshes in asset ({0}) is larger than the maximum number supported by Unity GUI ({1})." +
"\nImporting only the first {1} LOD meshes."
, m_LODCount, LODGroupGUI.kLODColors.Length);

// LODGroup GUI won't draw if we're above this limit, so we prevent future assertions here.
m_LODCount = (uint)LODGroupGUI.kLODColors.Length;
}

m_HasFacingData = TreeHasFacingData();
m_HasBranch2Data = m_Tree.Wind.DoBranch2;
m_LastLodIsBillboard = m_Tree.BillboardInfo.LastLodIsBillboard;
Expand Down Expand Up @@ -532,6 +540,7 @@ private void CalculateBillboardAndPerLODSettings()
}
else if (m_PerLODSettings.Count < m_LODCount)
{
m_PerLODSettings.Clear();
for (int i = 0; i < m_LODCount; ++i)
{
bool isBillboardLOD = m_LastLodIsBillboard && i == m_LODCount - 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,12 @@ private void DrawLODGroupFoldouts(List<LODGroupGUI.LODInfo> lods)
private string GetLODSubmeshAndTriCountLabel(int numLODs, int lodGroupIndex, SpeedTree9Importer im, LODGroup lodGroup)
{
LOD[] lods = lodGroup.GetLODs();
Debug.Assert(lods.Length == numLODs);

if(lods.Length != numLODs)
{
Debug.LogWarningFormat("Number of LODs mismatch between serialized object & LODGroup: {0}\nPlease re-import the asset and kindly report a bug if this warning keeps coming back.", im.assetPath);
numLODs = lods.Length;
}

int[][] primitiveCounts = new int[numLODs][];
int[] submeshCounts = new int[numLODs];
Expand Down Expand Up @@ -547,6 +552,11 @@ private string GetLODSubmeshAndTriCountLabel(int numLODs, int lodGroupIndex, Spe
return $"{totalTriCount} {LODGroupGUI.GUIStyles.m_TriangleCountLabel.text} {triangleChangeLabel} {submeshCountLabel}";
}

private Color GetLODGroupColor(int lodIndex)
{
return LODGroupGUI.kLODColors[lodIndex % LODGroupGUI.kLODColors.Length];
}

private void DrawLODGroupFoldout(Camera camera, int lodGroupIndex, ref SavedBool foldoutState, List<LODGroupGUI.LODInfo> lodInfoList)
{
GameObject[] ObjectArrayToGameObjectArray(UnityEngine.Object[] objects)
Expand Down Expand Up @@ -598,7 +608,7 @@ GameObject[] ObjectArrayToGameObjectArray(UnityEngine.Object[] objects)
, foldoutState.value
, LODFoldoutHeaderLabel
, m_LODColorTextures[lodGroupIndex]
, LODGroupGUI.kLODColors[lodGroupIndex] * 0.6f // 0.5f magic number is copied from LODGroupsGUI.cs
, GetLODGroupColor(lodGroupIndex) * 0.6f // 0.5f magic number is copied from LODGroupsGUI.cs
, LODFoldoutHeaderGroupAdditionalText
);

Expand Down Expand Up @@ -727,13 +737,13 @@ void InitAndSetFoldoutLabelTextures()
for (int i = 0; i < m_LODColorTextures.Length; i++)
{
m_LODColorTextures[i] = new Texture2D(1, 1);
m_LODColorTextures[i].SetPixel(0, 0, LODGroupGUI.kLODColors[i]);
m_LODColorTextures[i].SetPixel(0, 0, GetLODGroupColor(i));
}
}

void ResetFoldoutLists()
{
int lodArraySize = m_PerLODSettings.arraySize;
int lodArraySize = Mathf.Min(m_PerLODSettings.arraySize, LODGroupGUI.kLODColors.Length);
m_LODGroupFoldoutHeaderValues = new SavedBool[lodArraySize];
for (int i = 0; i < lodArraySize; i++)
{
Expand Down
9 changes: 9 additions & 0 deletions Editor/Mono/BuildProfile/BuildProfileModuleUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,5 +625,14 @@ static bool ShowRestartEditorDialog(string[] settingsRequiringRestart)
return EditorUtility.DisplayDialog(L10n.Tr("Unity editor restart required"),
editorPromptText.ToString(), L10n.Tr("Apply"), L10n.Tr("Cancel"));
}

internal static PlayerSettings GetBuildProfileOrGlobalPlayerSettings(BuildProfile buildProfile)
{
if (buildProfile == null || buildProfile.playerSettings == null)
{
return BuildProfile.GetGlobalPlayerSettings();
}
return buildProfile.playerSettings;
}
}
}
6 changes: 4 additions & 2 deletions Editor/Mono/EditorGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ void IDisposable.Dispose()
internal class RecycledTextEditor : TextEditor
{
internal static bool s_ActuallyEditing = false; // internal so we can save this state.
internal static bool s_EditingWasCompleted = false; // internal so we can save this state.
internal static bool s_AllowContextCutOrPaste = true; // e.g. selectable labels only allow for copying
private long[] s_OriginalLongValues;
private double[] s_OriginalDoubleValues;
Expand Down Expand Up @@ -585,6 +586,7 @@ public virtual void EndEditing()

controlID = 0;
s_ActuallyEditing = false;
s_EditingWasCompleted = false;
s_AllowContextCutOrPaste = true;
UnityEditor.Undo.IncrementCurrentGroup();

Expand Down Expand Up @@ -1022,8 +1024,8 @@ internal static string DoTextField(RecycledTextEditor editor, int id, Rect posit
}
}

// Inform editor that someone removed focus from us.
if (editor.controlID == id && GUIUtility.keyboardControl != id || (evt.type == EventType.ValidateCommand && evt.commandName == EventCommandNames.UndoRedoPerformed))
// Inform editor that someone removed focus from us or a rename operation was completed.
if (editor.controlID == id && GUIUtility.keyboardControl != id || EditorGUIUtility.renameWasCompleted || (evt.type == EventType.ValidateCommand && evt.commandName == EventCommandNames.UndoRedoPerformed))
{
editor.EndEditing();
}
Expand Down
6 changes: 6 additions & 0 deletions Editor/Mono/EditorGUIUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,12 @@ public static bool editingTextField
set { EditorGUI.RecycledTextEditor.s_ActuallyEditing = value; }
}

internal static bool renameWasCompleted
{
get { return EditorGUI.RecycledTextEditor.s_EditingWasCompleted; }
set { EditorGUI.RecycledTextEditor.s_EditingWasCompleted = value; }
}

public static bool textFieldHasSelection
{
get { return EditorGUI.s_RecycledEditor.hasSelection; }
Expand Down
2 changes: 2 additions & 0 deletions Editor/Mono/GUI/RenameOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public void EndRename(bool acceptChanges)
if (!m_IsRenaming)
return;

EditorGUIUtility.renameWasCompleted = true;

Undo.undoRedoEvent -= UndoRedoWasPerformed;
EditorApplication.update -= BeginRenameInternalCallback;

Expand Down
Loading