diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/Arrow.cs b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/Arrow.cs index f0e2baa85..9cd240a94 100644 --- a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/Arrow.cs +++ b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/Arrow.cs @@ -30,13 +30,18 @@ private void Start() ApplyMagnitude(_magnitude); // magnitude must be set after _capScale } +#if UNITY_EDITOR private void OnValidate() { - ApplyDirection(_direction); - ApplyCapScale(_capScale); - ApplyLineWidth(_lineWidth); - ApplyMagnitude(_magnitude); // magnitude must be set after _capScale + if (!UnityEditor.PrefabUtility.IsPartOfAnyPrefab(this)) + { + ApplyDirection(_direction); + ApplyCapScale(_capScale); + ApplyLineWidth(_lineWidth); + ApplyMagnitude(_magnitude); // magnitude must be set after _capScale + } } +#endif private Transform _cone; private Transform cone diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/CircleAnnotation.cs b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/CircleAnnotation.cs index 923456e10..4caf9f750 100644 --- a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/CircleAnnotation.cs +++ b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/CircleAnnotation.cs @@ -31,11 +31,16 @@ private void OnDisable() _lineRenderer.SetPositions(new Vector3[] { }); } +#if UNITY_EDITOR private void OnValidate() { - ApplyColor(_color); - ApplyLineWidth(_lineWidth); + if (!UnityEditor.PrefabUtility.IsPartOfAnyPrefab(this)) + { + ApplyColor(_color); + ApplyLineWidth(_lineWidth); + } } +#endif public void SetColor(Color color) { diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/ConnectionListAnnotation.cs b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/ConnectionListAnnotation.cs index 8d1f76a9a..6029d509a 100644 --- a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/ConnectionListAnnotation.cs +++ b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/ConnectionListAnnotation.cs @@ -19,11 +19,16 @@ public sealed class ConnectionListAnnotation : ListAnnotation connections, PointListAnnotation points) { diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/CuboidListAnnotation.cs b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/CuboidListAnnotation.cs index b3cffaf5a..fdf562701 100644 --- a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/CuboidListAnnotation.cs +++ b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/CuboidListAnnotation.cs @@ -22,15 +22,20 @@ public class CuboidListAnnotation : ListAnnotation [SerializeField] private float _arrowLengthScale = 1.0f; [SerializeField, Range(0, 1)] private float _arrowWidth = 1.0f; +#if UNITY_EDITOR private void OnValidate() { - ApplyPointColor(_pointColor); - ApplyLineColor(_lineColor); - ApplyLineWidth(_lineWidth); - ApplyArrowCapScale(_arrowCapScale); - ApplyArrowLengthScale(_arrowLengthScale); - ApplyArrowWidth(_arrowWidth); + if (!UnityEditor.PrefabUtility.IsPartOfAnyPrefab(this)) + { + ApplyPointColor(_pointColor); + ApplyLineColor(_lineColor); + ApplyLineWidth(_lineWidth); + ApplyArrowCapScale(_arrowCapScale); + ApplyArrowLengthScale(_arrowLengthScale); + ApplyArrowWidth(_arrowWidth); + } } +#endif public void SetPointColor(Color pointColor) { diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/DetectionListAnnotation.cs b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/DetectionListAnnotation.cs index 5721112ee..39ad5027d 100644 --- a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/DetectionListAnnotation.cs +++ b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/DetectionListAnnotation.cs @@ -9,20 +9,21 @@ namespace Mediapipe.Unity { -#pragma warning disable IDE0065 - using Color = UnityEngine.Color; -#pragma warning restore IDE0065 - public sealed class DetectionListAnnotation : ListAnnotation { [SerializeField, Range(0, 1)] private float _lineWidth = 1.0f; [SerializeField] private float _keypointRadius = 15.0f; +#if UNITY_EDITOR private void OnValidate() { - ApplyLineWidth(_lineWidth); - ApplyKeypointRadius(_keypointRadius); + if (!UnityEditor.PrefabUtility.IsPartOfAnyPrefab(this)) + { + ApplyLineWidth(_lineWidth); + ApplyKeypointRadius(_keypointRadius); + } } +#endif public void SetLineWidth(float lineWidth) { diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/LineAnnotation.cs b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/LineAnnotation.cs index a8eca7ddb..213e2094a 100644 --- a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/LineAnnotation.cs +++ b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/LineAnnotation.cs @@ -29,11 +29,16 @@ private void OnDisable() ApplyLineWidth(0.0f); } +#if UNITY_EDITOR private void OnValidate() { - ApplyColor(_color); - ApplyLineWidth(_lineWidth); + if (!UnityEditor.PrefabUtility.IsPartOfAnyPrefab(this)) + { + ApplyColor(_color); + ApplyLineWidth(_lineWidth); + } } +#endif public void SetColor(Color color) { diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/MaskAnnotation.cs b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/MaskAnnotation.cs index 7ddb281a6..587c5a8de 100644 --- a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/MaskAnnotation.cs +++ b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/MaskAnnotation.cs @@ -42,11 +42,16 @@ private void OnDisable() } } +#if UNITY_EDITOR private void OnValidate() { - ApplyMaskTexture(_maskTexture, _color); - ApplyThreshold(_threshold); + if (!UnityEditor.PrefabUtility.IsPartOfAnyPrefab(this)) + { + ApplyMaskTexture(_maskTexture, _color); + ApplyThreshold(_threshold); + } } +#endif private void OnDestroy() { diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/MultiFaceLandmarkListAnnotation.cs b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/MultiFaceLandmarkListAnnotation.cs index 0d7f0a579..0381b1830 100644 --- a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/MultiFaceLandmarkListAnnotation.cs +++ b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/MultiFaceLandmarkListAnnotation.cs @@ -24,17 +24,22 @@ public sealed class MultiFaceLandmarkListAnnotation : ListAnnotation [SerializeField] private Color _color = Color.green; [SerializeField] private float _radius = 15.0f; +#if UNITY_EDITOR private void OnValidate() { - ApplyColor(_color); - ApplyRadius(_radius); + if (!UnityEditor.PrefabUtility.IsPartOfAnyPrefab(this)) + { + ApplyColor(_color); + ApplyRadius(_radius); + } } +#endif public void SetColor(Color color) { diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/PoseLandmarkListAnnotation.cs b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/PoseLandmarkListAnnotation.cs index 7e82cac64..a0436c53e 100644 --- a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/PoseLandmarkListAnnotation.cs +++ b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/PoseLandmarkListAnnotation.cs @@ -121,11 +121,16 @@ private void Start() _connectionListAnnotation.Fill(_Connections, _landmarkListAnnotation); } +#if UNITY_EDITOR private void OnValidate() { - ApplyLeftLandmarkColor(_leftLandmarkColor); - ApplyRightLandmarkColor(_rightLandmarkColor); + if (!UnityEditor.PrefabUtility.IsPartOfAnyPrefab(this)) + { + ApplyLeftLandmarkColor(_leftLandmarkColor); + ApplyRightLandmarkColor(_rightLandmarkColor); + } } +#endif public void SetLeftLandmarkColor(Color leftLandmarkColor) { diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/RectangleAnnotation.cs b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/RectangleAnnotation.cs index ce46841f1..4339d824e 100644 --- a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/RectangleAnnotation.cs +++ b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/RectangleAnnotation.cs @@ -35,11 +35,16 @@ private void OnDisable() _lineRenderer.SetPositions(_EmptyPositions); } +#if UNITY_EDITOR private void OnValidate() { - ApplyColor(_color); - ApplyLineWidth(_lineWidth); + if (!UnityEditor.PrefabUtility.IsPartOfAnyPrefab(this)) + { + ApplyColor(_color); + ApplyLineWidth(_lineWidth); + } } +#endif public void SetColor(Color color) { diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/RectangleListAnnotation.cs b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/RectangleListAnnotation.cs index 580cb52dd..71b06dace 100644 --- a/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/RectangleListAnnotation.cs +++ b/Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/RectangleListAnnotation.cs @@ -18,11 +18,16 @@ public class RectangleListAnnotation : ListAnnotation [SerializeField] private Color _color = Color.red; [SerializeField, Range(0, 1)] private float _lineWidth = 1.0f; +#if UNITY_EDITOR private void OnValidate() { - ApplyColor(_color); - ApplyLineWidth(_lineWidth); + if (!UnityEditor.PrefabUtility.IsPartOfAnyPrefab(this)) + { + ApplyColor(_color); + ApplyLineWidth(_lineWidth); + } } +#endif public void SetColor(Color color) {