Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private static GUIContent GetEditorTitle(InputActionAsset asset, bool isDirty)
return new GUIContent(text);
}

private void SetAsset(InputActionAsset asset, string actionToSelect = null, string actionMapToSelect = null)
private void SetAsset(InputActionAsset asset, string actionToSelect = null, string actionMapToSelect = null, bool shouldClearRootVisualElement = true)
{
var existingWorkingCopy = m_AssetObjectForEditing;

Expand All @@ -188,7 +188,7 @@ private void SetAsset(InputActionAsset asset, string actionToSelect = null, stri
m_State = m_State.SelectAction(actionToSelect);
}

BuildUI();
BuildUI(shouldClearRootVisualElement);
}
catch (Exception e)
{
Expand All @@ -197,7 +197,9 @@ private void SetAsset(InputActionAsset asset, string actionToSelect = null, stri
finally
{
if (existingWorkingCopy != null)
{
DestroyImmediate(existingWorkingCopy);
}
}
}

Expand Down Expand Up @@ -259,7 +261,7 @@ private void CleanupStateContainer()
}
}

private void BuildUI()
private void BuildUI(bool shouldClearRoot = true)
{
CleanupStateContainer();

Expand All @@ -269,11 +271,14 @@ private void BuildUI()
m_StateContainer = new StateContainer(m_State, m_AssetGUID);
m_StateContainer.StateChanged += OnStateChanged;

rootVisualElement.Clear();
if (shouldClearRoot)
{
rootVisualElement.Clear();
}

if (!rootVisualElement.styleSheets.Contains(InputActionsEditorWindowUtils.theme))
rootVisualElement.styleSheets.Add(InputActionsEditorWindowUtils.theme);
m_View = new InputActionsEditorView(rootVisualElement, m_StateContainer, false, () => Save(isAutoSave: false));

m_StateContainer.Initialize(rootVisualElement.Q("action-editor"));
}

Expand Down Expand Up @@ -303,6 +308,11 @@ private InputActionAsset GetEditedAsset()

private void Save(bool isAutoSave)
{
if (isAutoSave)
{
Debug.LogError("Auto-saving input action asset.");
}

var path = AssetDatabase.GUIDToAssetPath(m_AssetGUID);
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
var projectWideActions = InputSystem.actions;
Expand Down Expand Up @@ -447,8 +457,7 @@ private bool TryUpdateFromAsset()
var assetPath = AssetDatabase.GUIDToAssetPath(m_AssetGUID);
if (assetPath == null)
{
Debug.LogWarning(
$"Failed to open InputActionAsset with GUID {m_AssetGUID}. The asset might have been deleted.");
Debug.LogWarning($"Failed to open InputActionAsset with GUID {m_AssetGUID}. The asset might have been deleted.");
return false;
}

Expand All @@ -458,7 +467,9 @@ private bool TryUpdateFromAsset()
var asset = AssetDatabase.LoadAssetAtPath<InputActionAsset>(assetPath);
workingCopy = InputActionAssetManager.CreateWorkingCopy(asset);
m_AssetJson = InputActionsEditorWindowUtils.ToJsonWithoutName(asset);

m_State = new InputActionsEditorState(m_State, new SerializedObject(workingCopy));
//TODO THIS CAUSES THE ERROR
m_IsDirty = false;
}
catch (Exception e)
Expand Down Expand Up @@ -501,7 +512,9 @@ public void OnAssetImported()
// is not much we can do about it but to ignore loading the changes. If the editors asset is
// unmodified, we can refresh the editor with the latest content from disc.
if (m_IsDirty)
{
return;
}

// If our asset has disappeared from disk, just close the window.
var assetPath = AssetDatabase.GUIDToAssetPath(assetGUID);
Expand All @@ -512,7 +525,8 @@ public void OnAssetImported()
return;
}

SetAsset(AssetDatabase.LoadAssetAtPath<InputActionAsset>(assetPath));
// We set shouldClearRootVisualElement to false here as we don't want the root visual element's child elements to be closed during an auto save.
SetAsset(AssetDatabase.LoadAssetAtPath<InputActionAsset>(assetPath), shouldClearRootVisualElement: false);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public override void RedrawUI(InputControlScheme viewState)

public override void DestroyView()
{
Debug.LogError("Destroying view! ");

m_ModalWindow.RemoveFromHierarchy();
}

Expand Down Expand Up @@ -145,6 +147,7 @@ private void CloseView()
// the changes retained. However, if a different ControlScheme is selected or the Asset
// Editor window is closed, then the changes are lost.

Debug.LogError("Closing the control scheme view here");
m_NewName = string.Empty;
OnClosing?.Invoke(this);
}
Expand Down