Skip to content

Commit

Permalink
Unity 2022.2.0a9 C# reference source code
Browse files Browse the repository at this point in the history
  • Loading branch information
Unity Technologies committed Apr 1, 2022
1 parent d0fe81a commit c84064b
Show file tree
Hide file tree
Showing 1,117 changed files with 41,160 additions and 22,555 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class Il2CppConfig
public bool EnableDeepProfilingSupport;
public bool EnableFullGenericSharing;
public string Profile;
public string Defines;

public string ConfigurationName;
public bool GcWBarrierValidation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class AssemblyData
public string[] CustomCompilerOptions = new string[0];
public int DebugIndex;
public bool SkipCodeGen;
public string Path;
}

public class ScriptCompilationData_Out
Expand Down
2 changes: 1 addition & 1 deletion Editor/Mono/2D/Common/TexturePlatformSettingsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Styles
public readonly GUIContent compressionQualityLabel = EditorGUIUtility.TrTextContent("Compressor Quality");
public readonly GUIContent compressionQualitySliderLabel = EditorGUIUtility.TrTextContent("Compressor Quality", "Use the slider to adjust compression quality from 0 (Fastest) to 100 (Best)");

public readonly int[] kMaxTextureSizeValues = { 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 };
public readonly int[] kMaxTextureSizeValues = { 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384 };
public readonly GUIContent[] kMaxTextureSizeStrings;

public readonly GUIContent[] kTextureCompressionOptions =
Expand Down
30 changes: 3 additions & 27 deletions Editor/Mono/2D/SpriteAtlas/SpriteAtlasImporterInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,6 @@ protected override void Apply()
base.Apply();
}

public void ApplyAndImportSpriteAtlas()
{
Apply();
base.ApplyAndImport();
}

protected void PackPreviewGUI()
{
EditorGUILayout.Space();
Expand All @@ -432,7 +426,7 @@ protected void PackPreviewGUI()
{
GUI.FocusControl(null);
SpriteAtlasUtility.EnableV2Import(true);
ApplyAndImportSpriteAtlas();
SaveChanges();
SpriteAtlasUtility.EnableV2Import(false);
}
}
Expand All @@ -447,26 +441,6 @@ private bool IsValidAtlas()
return true;
}

public override void OnDisable()
{

if (Unsupported.IsDestroyScriptableObject(this))
{
if (spriteAtlasAsset && HasModified())
{
if (EditorUtility.DisplayDialog("Unapplied import settings", "Unapplied import settings for \'" + m_AssetPath + "\'", "Apply", "Revert"))
{
ApplyAndImportSpriteAtlas();
}
else
{
ResetValues();
}
}
}
base.OnDisable();
}

public override bool HasModified()
{
return base.HasModified() || m_ContentHash != GetInspectorHash();
Expand Down Expand Up @@ -535,6 +509,8 @@ public override void OnInspectorGUI()
serializedAssetObject.ApplyModifiedProperties();
PackPreviewGUI();
}

ApplyRevertGUI();
}

private void HandleCommonSettingUI()
Expand Down
13 changes: 13 additions & 0 deletions Editor/Mono/ActiveEditorTracker.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.Bindings;
using UnityEngine.Scripting;
using UnityObject = UnityEngine.Object;

namespace UnityEditor
Expand All @@ -15,6 +16,7 @@ namespace UnityEditor
// Might want to add a manual dispose
[NativeHeader("Editor/Src/Utility/ActiveEditorTracker.bindings.h")]
[Serializable]
[RequiredByNativeCode]
public sealed class ActiveEditorTracker
{
#pragma warning disable 649
Expand Down Expand Up @@ -113,6 +115,17 @@ public bool isLocked
set { Internal_SetIsLocked(this, value); }
}

[FreeFunction]
static extern bool Internal_HasUnsavedChanges(ActiveEditorTracker activeEditorTracker);
public bool hasUnsavedChanges => Internal_HasUnsavedChanges(this);

[FreeFunction]
static extern void Internal_UnsavedChangesStateChanged(ActiveEditorTracker self, int editorInstance, bool value);
internal void UnsavedChangesStateChanged(Editor editor, bool value)
{
Internal_UnsavedChangesStateChanged(this, editor.GetInstanceID(), value);
}

[FreeFunction]
static extern bool Internal_GetDelayFlushDirtyRebuild();

Expand Down
2 changes: 2 additions & 0 deletions Editor/Mono/Animation/AnimationUtility.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ internal static System.Type GetEditorCurveValueType(ScriptableObject scriptableO
extern private static System.Type Internal_GetScriptableObjectEditorCurveValueType([NotNull] ScriptableObject scriptableObject, EditorCurveBinding binding);

extern public static bool GetFloatValue([NotNull] GameObject root, EditorCurveBinding binding, out float data);
extern public static bool GetDiscreteIntValue([NotNull] GameObject root, EditorCurveBinding binding, out int data);
public static bool GetObjectReferenceValue(GameObject root, EditorCurveBinding binding, out Object data)
{
data = Internal_GetObjectReferenceValue(root, binding);
Expand Down Expand Up @@ -388,6 +389,7 @@ public static AnimationCurve GetEditorCurve(AnimationClip clip, string relativeP
extern public static string CalculateTransformPath([NotNull] Transform targetTransform, Transform root);

extern public static AnimationClipSettings GetAnimationClipSettings([NotNull] AnimationClip clip);
extern internal static void RebuildMecanimData([NotNull] AnimationClip clip);
extern public static void SetAnimationClipSettings([NotNull] AnimationClip clip, AnimationClipSettings srcClipInfo);
extern internal static void SetAnimationClipSettingsNoDirty([NotNull] AnimationClip clip, AnimationClipSettings srcClipInfo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, GameObject
// Don't show for the root go
if (curveBinding.path != "")
{
TreeViewItem newNode = CreateNode(singleObjectBindings.ToArray(), node);
TreeViewItem newNode = CreateNode(singleObjectBindings.ToArray(), node, null);
if (newNode != null)
childNodes.Add(newNode);
singleObjectBindings.Clear();
Expand Down Expand Up @@ -111,20 +111,6 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, GameObject
}
}

var animator = rootGameObject.GetComponent<Animator>();
if (animator != null)
{
//If the Animator has a human avatar, we need to check if the avatar's hierarchy matches that of the current GameObject. If they do not match, disable the node.
if (animator.avatarRoot != null && animator.isHuman)
{
if (animator.avatarRoot.Find(path) == null)
{
node.propertyPathMismatchWithHumanAvatar = true;
}
}
}


if (showEntireHierarchy)
{
// Iterate over all child GOs
Expand All @@ -137,6 +123,13 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, GameObject
}
}

// Remove Leaf nodes without properties.
if (childNodes.Count == 0)
{
node.parent = null;
return null;
}

TreeViewUtility.SetChildParentReferences(childNodes, node);
return node;
}
Expand Down Expand Up @@ -191,17 +184,24 @@ private TreeViewItem AddAnimatableObjectToHierarchy(EditorCurveBinding[] curveBi

List<TreeViewItem> childNodes = new List<TreeViewItem>();
List<EditorCurveBinding> singlePropertyBindings = new List<EditorCurveBinding>();
SerializedObject so = null;

for (int i = 0; i < curveBindings.Length; i++)
{
EditorCurveBinding curveBinding = curveBindings[i];
if (curveBinding.isSerializeReferenceCurve)
{
var animatedObject = AnimationUtility.GetAnimatedObject(AddCurvesPopup.s_State.activeRootGameObject, curveBinding);
if (animatedObject != null && (so == null || so.targetObject != animatedObject))
so = new SerializedObject(animatedObject);
}

singlePropertyBindings.Add(curveBinding);

// We expect curveBindings to come sorted by propertyname
if (i == curveBindings.Length - 1 || AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(curveBinding.propertyName))
{
TreeViewItem newNode = CreateNode(singlePropertyBindings.ToArray(), node);
TreeViewItem newNode = CreateNode(singlePropertyBindings.ToArray(), node, so);
if (newNode != null)
childNodes.Add(newNode);
singlePropertyBindings.Clear();
Expand All @@ -214,9 +214,9 @@ private TreeViewItem AddAnimatableObjectToHierarchy(EditorCurveBinding[] curveBi
return node;
}

private TreeViewItem CreateNode(EditorCurveBinding[] curveBindings, TreeViewItem parentNode)
private TreeViewItem CreateNode(EditorCurveBinding[] curveBindings, TreeViewItem parentNode, SerializedObject so)
{
var node = new AddCurvesPopupPropertyNode(parentNode, curveBindings);
var node = new AddCurvesPopupPropertyNode(parentNode, curveBindings, AnimationWindowUtility.GetNicePropertyDisplayName(curveBindings[0], so));

// For RectTransform.position we only want .z
if (AnimationWindowUtility.IsRectTransformPosition(node.curveBindings[0]))
Expand All @@ -234,7 +234,6 @@ public void UpdateData()

internal class AddCurvesPopupGameObjectNode : TreeViewItem
{
internal bool propertyPathMismatchWithHumanAvatar = false;
public AddCurvesPopupGameObjectNode(GameObject gameObject, TreeViewItem parent, string displayName)
: base(gameObject.GetInstanceID(), parent != null ? parent.depth + 1 : -1, parent, displayName)
{
Expand All @@ -253,8 +252,8 @@ internal class AddCurvesPopupPropertyNode : TreeViewItem
{
public EditorCurveBinding[] curveBindings;

public AddCurvesPopupPropertyNode(TreeViewItem parent, EditorCurveBinding[] curveBindings)
: base(curveBindings[0].GetHashCode(), parent.depth + 1, parent, AnimationWindowUtility.NicifyPropertyGroupName(curveBindings[0].type, AnimationWindowUtility.GetPropertyGroupName(curveBindings[0].propertyName)))
public AddCurvesPopupPropertyNode(TreeViewItem parent, EditorCurveBinding[] curveBindings, string displayPath)
: base(curveBindings[0].GetHashCode(), parent.depth + 1, parent, displayPath)
{
this.curveBindings = curveBindings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,17 @@ internal class AddCurvesPopupHierarchyGUI : TreeViewGUI
private GUIContent addPropertiesContent = EditorGUIUtility.TrTextContent("Add Properties");
private const float plusButtonWidth = 17;

static Texture2D warningIcon = (Texture2D)EditorGUIUtility.LoadRequired("Icons/ShortcutManager/alertDialog.png");
public static GUIStyle warningIconStyle;

public AddCurvesPopupHierarchyGUI(TreeViewController treeView, EditorWindow owner)
: base(treeView, true)
{
this.owner = owner;
warningIconStyle = new GUIStyle();
warningIconStyle.margin = new RectOffset(15, 15, 15, 15);
}

public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused)
{
bool propertyPathMismatchWithHumanAvatar = false;
AddCurvesPopupGameObjectNode addCurvesPopupNode = node as AddCurvesPopupGameObjectNode;
if (addCurvesPopupNode != null)
{
propertyPathMismatchWithHumanAvatar = addCurvesPopupNode.propertyPathMismatchWithHumanAvatar;
}

using (new EditorGUI.DisabledScope(propertyPathMismatchWithHumanAvatar))
{
base.OnRowGUI(rowRect, node, row, selected, focused);
DoAddCurveButton(rowRect, node);
HandleContextMenu(rowRect, node);
}

if (propertyPathMismatchWithHumanAvatar)
{
Rect iconRect = new Rect(rowRect.width - plusButtonWidth, rowRect.yMin, plusButtonWidth, buttonStyle.fixedHeight);
GUI.Label(iconRect, new GUIContent(warningIcon, "The Avatar definition does not match the property path. Please author using a hierarchy the Avatar was built with."), warningIconStyle);
}
base.OnRowGUI(rowRect, node, row, selected, focused);
DoAddCurveButton(rowRect, node);
HandleContextMenu(rowRect, node);
}

private void DoAddCurveButton(Rect rowRect, TreeViewItem node)
Expand Down
6 changes: 0 additions & 6 deletions Editor/Mono/Animation/AnimationWindow/AnimationRecording.cs
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,6 @@ static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, T
{
if (state.currentFrame != 0)
{
// case 1373924
// In the case of a new curve, we also have to convert the previousValue to float for a discrete int
if(binding.isDiscreteCurve)
{
previousValue = UnityEngine.Animations.DiscreteEvaluationAttributeUtilities.ConvertDiscreteIntToFloat((int)previousValue);
}
AnimationWindowUtility.AddKeyframeToCurve(curve, previousValue, type, AnimationKeyTime.Frame(0, clip.frameRate));
}
}
Expand Down
6 changes: 3 additions & 3 deletions Editor/Mono/Animation/AnimationWindow/AnimationWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,15 @@ void OnEnable()

OnSelectionChange();

Undo.undoRedoPerformed += UndoRedoPerformed;
Undo.undoRedoEvent += UndoRedoPerformed;
}

void OnDisable()
{
s_AnimationWindows.Remove(this);
m_AnimEditor.OnDisable();

Undo.undoRedoPerformed -= UndoRedoPerformed;
Undo.undoRedoEvent -= UndoRedoPerformed;
}

void OnDestroy()
Expand Down Expand Up @@ -452,7 +452,7 @@ private bool ShouldUpdateSelection(AnimationWindowSelectionItem selectedItem)
return (selectedItem.GetRefreshHash() != currentSelection.GetRefreshHash());
}

private void UndoRedoPerformed()
private void UndoRedoPerformed(in UndoRedoInfo info)
{
Repaint();
}
Expand Down
Loading

0 comments on commit c84064b

Please sign in to comment.