Skip to content

Commit

Permalink
Merge branch 'main' into feature/eigen-3d-tiles-inladen-assets-verpla…
Browse files Browse the repository at this point in the history
…atsen-naar-functionalities-ogc3dtiles
  • Loading branch information
bozmir committed Oct 17, 2024
2 parents a353272 + 3d8d498 commit d791c89
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 20 deletions.
56 changes: 56 additions & 0 deletions Assets/Prefabs/ObjImporter.prefab

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Assets/Prefabs/ObjImporter.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions Assets/Scripts/Layers/DragGhost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

namespace Netherlands3D.Twin.UI.LayerInspector
{
public class DragGhost : MonoBehaviour//, IPointerDownHandler, IPointerUpHandler
public class DragGhost : MonoBehaviour //, IPointerDownHandler, IPointerUpHandler
{
private Vector2 DragStartOffset { get; set; }

[SerializeField] private Image layerVisibilityImage;
[SerializeField] private Image colorImage;
[SerializeField] private Image foldoutImage;
Expand All @@ -21,7 +21,7 @@ public void Initialize(Vector2 dragStartOffset, LayerUI ui)
// var pointerPosition = Pointer.current.position.ReadValue();
DragStartOffset = dragStartOffset;
CalculateNewPosition();

CopyAppearance(ui);
}

Expand All @@ -32,8 +32,11 @@ private void CopyAppearance(LayerUI ui)
foldoutImage.enabled = ui.hasChildren;
layerTypeImage.sprite = ui.LayerTypeSprite;
layerNameText.text = ui.LayerName;

var credentialsUI = GetComponent<LayerUICredentialsNeededListener>();
credentialsUI.layerUI = ui;
}

void Update()
{
CalculateNewPosition();
Expand Down
29 changes: 19 additions & 10 deletions Assets/Scripts/Layers/LayerTypes/LayerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,31 @@ public void SetParent(LayerData newParent, int siblingIndex = -1)

if (newParent == this)
return;

var parentChanged = ParentLayer != newParent;
var oldSiblingIndex = SiblingIndex;

parent.children.Remove(this);
if (!parentChanged && siblingIndex > oldSiblingIndex) //if the parent did not change, and the new sibling index is larger than the old sibling index, we need to decrease the new siblingIndex by 1 because we previously removed one item from the children list
siblingIndex--;
parent.ChildrenChanged.Invoke(); //call event on old parent

if (siblingIndex < 0)
siblingIndex = newParent.children.Count;

if (!parentChanged && siblingIndex > oldSiblingIndex) // moved down: insert first, remove after to keep the correct indices
{
parent = newParent;
newParent.children.Insert(siblingIndex, this);

parent.children.RemoveAt(oldSiblingIndex);
parent.ChildrenChanged.Invoke(); //call event on old parent
}
else
{
parent.children.RemoveAt(oldSiblingIndex);

parent = newParent;

newParent.children.Insert(siblingIndex, this);

parent = newParent;
newParent.children.Insert(siblingIndex, this);

parent.ChildrenChanged.Invoke(); //call event on old parent
}

if (parentChanged || siblingIndex != oldSiblingIndex)
{
LayerActiveInHierarchyChanged.Invoke(ActiveInHierarchy);
Expand Down
9 changes: 3 additions & 6 deletions Assets/Scripts/Layers/LayerUICredentialsNeededListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace Netherlands3D.Twin
{
public class LayerUICredentialsNeededListener : MonoBehaviour
{
private LayerUI layerUI;
private LayerUIManager layerUIManager;
public LayerUI layerUI { get; set; }

[SerializeField] private GameObject visibilityToggle;
[SerializeField] private GameObject warningIcon;
Expand All @@ -31,14 +30,13 @@ public class LayerUICredentialsNeededListener : MonoBehaviour

private void Awake()
{
layerUI = GetComponent<LayerUI>();
layerUIManager = GetComponentInParent<LayerUIManager>();
if(!layerUI)
layerUI = GetComponent<LayerUI>();
}

private void Start()
{
originalTextColor = layerNameText.color;

SetUI(layerUI.Layer.HasValidCredentials); //set initial state
layerUI.Layer.HasValidCredentialsChanged.AddListener(SetUI);
}
Expand All @@ -60,7 +58,6 @@ private void SetUI(bool hasValidCredentials)

private void OnDestroy()
{
var layerUI = GetComponent<LayerUI>();
layerUI.Layer.HasValidCredentialsChanged.RemoveListener(SetUI);
}
}
Expand Down

0 comments on commit d791c89

Please sign in to comment.