-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'release/6.7.0' into openupm
- Loading branch information
Showing
101 changed files
with
1,924 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"DefineConstants": "DRACO_UNITY;KTX_UNITY;KTX_UNITY_1_3_OR_NEWER;KTX_UNITY_2_2_OR_NEWER;USING_URP;USING_HDRP;USING_HDRP_10_OR_NEWER;UNITY_PHYSICS;UNITY_IMAGECONVERSION;UNITY_WEBREQUEST_TEXTURE;MESHOPT;USING_URP_12_OR_NEWER;UNITY_SHADER_GRAPH_12_OR_NEWER;UNITY_ANIMATION;UNITY_ENTITIES_GRAPHICS;NEWTONSOFT_JSON" | ||
"DefineConstants": "DRACO_UNITY;KTX_UNITY;KTX_UNITY_1_3_OR_NEWER;KTX_UNITY_2_2_OR_NEWER;USING_URP;USING_HDRP;USING_HDRP_10_OR_NEWER;UNITY_PHYSICS;UNITY_IMAGECONVERSION;UNITY_WEBREQUEST_TEXTURE;MESHOPT;USING_URP_12_OR_NEWER;UNITY_SHADER_GRAPH;UNITY_SHADER_GRAPH_12_OR_NEWER;UNITY_ANIMATION;UNITY_ENTITIES_GRAPHICS;NEWTONSOFT_JSON" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Collections.Generic; | ||
using UnityEditor; | ||
using UnityEngine; | ||
using UnityEngine.UIElements; | ||
|
||
namespace GLTFast.Editor | ||
{ | ||
[CustomEditor(typeof(MaterialsVariantsComponent))] | ||
class MaterialsVariantsComponentInspector : UnityEditor.Editor | ||
{ | ||
[SerializeField] VisualTreeAsset m_MainMarkup; | ||
|
||
List<string> m_VariantNames; | ||
#if UNITY_2021_2_OR_NEWER | ||
DropdownField m_Dropdown; | ||
#endif | ||
|
||
public override VisualElement CreateInspectorGUI() | ||
{ | ||
if (m_VariantNames == null) | ||
{ | ||
var control = (target as MaterialsVariantsComponent)?.Control; | ||
if (control != null) | ||
{ | ||
var count = control.MaterialsVariantsCount; | ||
m_VariantNames = new List<string>(count + 1) | ||
{ | ||
"<no variant>" | ||
}; | ||
for (var variantIndex = 0; variantIndex < count; variantIndex++) | ||
{ | ||
m_VariantNames.Add(control.GetMaterialsVariantName(variantIndex)); | ||
} | ||
} | ||
} | ||
var myInspector = new VisualElement(); | ||
#if UNITY_2021_2_OR_NEWER | ||
m_MainMarkup.CloneTree(myInspector); | ||
m_Dropdown = myInspector.Query<DropdownField>().First(); | ||
|
||
if (m_VariantNames == null) | ||
{ | ||
myInspector.SetEnabled(false); | ||
} | ||
else | ||
{ | ||
m_Dropdown.choices = m_VariantNames; | ||
m_Dropdown.index = 0; | ||
m_Dropdown.RegisterValueChangedCallback(OnMaterialsVariantChanged); | ||
myInspector.Add(m_Dropdown); | ||
} | ||
#else | ||
if (m_VariantNames == null) | ||
{ | ||
myInspector.SetEnabled(false); | ||
} | ||
else | ||
{ | ||
for (var i = 0; i < m_VariantNames.Count; i++) | ||
{ | ||
var button = new Button | ||
{ | ||
text = m_VariantNames[i] | ||
}; | ||
|
||
button.RegisterCallback<ClickEvent, int>(OnVariantButtonClicked, i - 1); // asset is the root visual element that will be closed | ||
myInspector.Add(button); | ||
} | ||
} | ||
#endif | ||
return myInspector; | ||
} | ||
|
||
#if UNITY_2021_2_OR_NEWER | ||
void OnMaterialsVariantChanged(ChangeEvent<string> evt) | ||
{ | ||
var control = (target as MaterialsVariantsComponent)?.Control; | ||
if (control != null) | ||
{ | ||
_ = control.ApplyMaterialsVariantAsync(m_Dropdown.index - 1); | ||
} | ||
} | ||
#else | ||
void OnVariantButtonClicked(ClickEvent evt, int variantIndex) | ||
{ | ||
var control = (target as MaterialsVariantsComponent)?.Control; | ||
if (control != null) | ||
{ | ||
_ = control.ApplyMaterialsVariantAsync(variantIndex); | ||
} | ||
} | ||
#endif | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Editor/Scripts/MaterialsVariantsComponentInspector.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False"> | ||
<ui:DropdownField label="Materials Variant" /> | ||
</ui:UXML> |
Oops, something went wrong.