From 311717d3f7228478ad40103c968b2269bcf041c2 Mon Sep 17 00:00:00 2001 From: bozmir Date: Tue, 29 Oct 2024 12:26:50 +0100 Subject: [PATCH] resolved pr comments --- .../HierarchicalObjectLayerGameObject.cs | 12 ++---------- .../HierarchicalStaticObjectLayerGameObject.cs | 16 ++++++---------- Assets/Scripts/Projects/PrefabLibrary.cs | 1 - .../AssetBundles/Scripts/AssetBundleLoader.cs | 15 --------------- 4 files changed, 8 insertions(+), 36 deletions(-) diff --git a/Assets/Scripts/Layers/LayerTypes/HierarchicalObjectLayerGameObject.cs b/Assets/Scripts/Layers/LayerTypes/HierarchicalObjectLayerGameObject.cs index 09db4e35..227302d5 100644 --- a/Assets/Scripts/Layers/LayerTypes/HierarchicalObjectLayerGameObject.cs +++ b/Assets/Scripts/Layers/LayerTypes/HierarchicalObjectLayerGameObject.cs @@ -16,29 +16,21 @@ public class HierarchicalObjectLayerGameObject : LayerGameObject, IPointerClickH private ToggleScatterPropertySectionInstantiator toggleScatterPropertySectionInstantiator; [SerializeField] private UnityEvent objectCreated = new(); private List propertySections = new(); - private TransformLayerPropertyData transformPropertyData; + protected TransformLayerPropertyData transformPropertyData; private Vector3 previousPosition; private Quaternion previousRotation; private Vector3 previousScale; - protected Coordinate coord; - LayerPropertyData ILayerWithPropertyData.PropertyData => transformPropertyData; protected void Awake() { - InitializeCoordinates(); - transformPropertyData = new TransformLayerPropertyData(coord, transform.eulerAngles, transform.localScale); + transformPropertyData = new TransformLayerPropertyData(new Coordinate(transform.position), transform.eulerAngles, transform.localScale); propertySections = GetComponents().ToList(); toggleScatterPropertySectionInstantiator = GetComponent(); } - protected virtual void InitializeCoordinates() - { - coord = new Coordinate(transform.position); - } - protected override void OnEnable() { base.OnEnable(); diff --git a/Assets/Scripts/Layers/LayerTypes/HierarchicalStaticObjectLayerGameObject.cs b/Assets/Scripts/Layers/LayerTypes/HierarchicalStaticObjectLayerGameObject.cs index b905c710..330bc59f 100644 --- a/Assets/Scripts/Layers/LayerTypes/HierarchicalStaticObjectLayerGameObject.cs +++ b/Assets/Scripts/Layers/LayerTypes/HierarchicalStaticObjectLayerGameObject.cs @@ -8,20 +8,16 @@ public class HierarchicalStaticObjectLayerGameObject : HierarchicalObjectLayerGa public Vector3 Rotation = Vector3.zero; //TODO get this value from original template public Vector3 Scale = Vector3.one; //TODO get this value from original template public float TargetHeight; - public Vector2 Coordinates = Vector2.zero; + public Vector3 Coordinates = Vector3.zero; [SerializeField] private CoordinateSystem coordinateSystem; - protected override void InitializeCoordinates() - { - coord = new Coordinate(coordinateSystem, new double[3] { Coordinates.y, Coordinates.x, 0 }); - } protected override void Start() { base.Start(); - UpdatePosition(coord); - UpdateRotation(Rotation); - UpdateScale(Scale); + transformPropertyData.Position = new Coordinate(coordinateSystem, new double[3] { Coordinates.y, Coordinates.x, Coordinates.z }); + transformPropertyData.EulerRotation = Rotation; + transformPropertyData.LocalScale = Scale; } protected override void UpdatePosition(Coordinate newPosition) @@ -32,12 +28,12 @@ protected override void UpdatePosition(Coordinate newPosition) public override void OnSelect() { - + //this is to prevent executing base class functionality } public override void OnDeselect() { - + //this is to prevent executing base class functionality } } } diff --git a/Assets/Scripts/Projects/PrefabLibrary.cs b/Assets/Scripts/Projects/PrefabLibrary.cs index 4001c901..c2999462 100644 --- a/Assets/Scripts/Projects/PrefabLibrary.cs +++ b/Assets/Scripts/Projects/PrefabLibrary.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using netDxf.Collections; using Netherlands3D.Twin.Layers; using Newtonsoft.Json; using UnityEngine; diff --git a/Assets/_Functionalities/AssetBundles/Scripts/AssetBundleLoader.cs b/Assets/_Functionalities/AssetBundles/Scripts/AssetBundleLoader.cs index d1a9c628..09b0f00d 100644 --- a/Assets/_Functionalities/AssetBundles/Scripts/AssetBundleLoader.cs +++ b/Assets/_Functionalities/AssetBundles/Scripts/AssetBundleLoader.cs @@ -29,19 +29,12 @@ public class AssetBundleLoader : MonoBehaviour public string prefabName; public Vector3 spawnPosition; - public static List hierarchicalObjectLayerGameObjects = new List(); - private void Awake() { ProjectData.Current.PrefabLibrary.AddPrefabGroupRuntime("ObjectenBibliotheek"); OnProjectDataChanged(ProjectData.Current); } - private void Start() - { - //ProjectData.Current.OnDataChanged.AddListener(OnProjectDataChanged); - } - private void OnProjectDataChanged(ProjectData projectData) { //we want only the original asset here and not an instantiation @@ -51,8 +44,6 @@ private void OnProjectDataChanged(ProjectData projectData) if (layerObject != null) { projectData.PrefabLibrary.AddObjectToPrefabGroupRuntime("ObjectenBibliotheek", layerObject); - if(!hierarchicalObjectLayerGameObjects.Contains(layerObject)) - hierarchicalObjectLayerGameObjects.Add(layerObject); } }); } @@ -138,11 +129,5 @@ public IEnumerator GetAssetBundle(string path, UnityAction callBack callBack?.Invoke(bundle); } } - - private void OnDestroy() - { - //ProjectData.Current.OnDataChanged.RemoveListener(OnProjectDataChanged); - hierarchicalObjectLayerGameObjects.Clear(); - } } }