using System.Collections; using System.Collections.Generic; using System.Linq; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; public class MovableFurniture : MonoBehaviour { private List children; private List outlines; private Rigidbody _rigidbody; // Start is called before the first frame update void Start() { _rigidbody = GetComponent(); children = new List(GetComponentsInChildren()); outlines = new List(); foreach (Transform child in children) { var part = child.gameObject.AddComponent(); part.parent = this; var outline = child.gameObject.AddComponent(); outlines.Add(outline); outline.OutlineMode = ObjectOutline.Mode.OutlineAll; outline.OutlineColor = Color.yellow; outline.OutlineWidth = 5f; outline.enabled = false; } } // Update is called once per frame void Update() { } public void OnPointerClickUp() { if (_rigidbody != null) { _rigidbody.useGravity = true; } } public void OnPointerClickDown() { if(_rigidbody!= null) { _rigidbody.useGravity= false; } } public void OnPointerEnter() { foreach (ObjectOutline outline in outlines) { /*child.OutlineMode = ObjectOutline.Mode.OutlineAll; child.OutlineColor = Color.yellow; child.OutlineWidth = 5f;*/ outline.enabled = true; } } public void OnPointerExit() { foreach (ObjectOutline outline in outlines) { outline.enabled = false; } } }