а ведь если я не ошибаюсь переопределяет метод и для родителя тоже.
public partial class Form1 : Form
{
List<Label> Labels { get; }
public Form1()
{
InitializeComponent();
//1 Вариант: Коллекция со всеми нужными лейблами.
//Обратите внимание, что используются сами КОНТРОЛЫ, а НЕ их ИМЕНА.
Labels = new List<Label> { label1, label2, label3, label4, label5, label6, label7, label8, label9, label10, label11, label12, label13, label14, label15, label16 };
Labels.ForEach(x => x.Visible = true);
Labels.ForEach(x => x.Visible = false);
//2 Вариант: Перебор ВСЕХ(!) контролов на форме.
foreach (var item in Controls)
if (item is Label)
((Label)item).Visible = true;
foreach (var item in Controls)
if (item is Label)
((Label)item).Visible = false;
}
}
using UnityEngine;
public class LineExample : MonoBehaviour
{
public LineRenderer lineRenderer;
public Transform a;
public Transform b;
public float sphereRadius = 0.5f;
public int positionCount = 10;
private void Awake()
{
Vector3 aDirection = transform.InverseTransformPoint(a.position).normalized;
Vector3 bDirection = transform.InverseTransformPoint(b.position).normalized;
var fromRotation = Quaternion.identity;
var toRotation = Quaternion.FromToRotation(aDirection, bDirection);
lineRenderer.positionCount = positionCount;
for (int i = 0; i < positionCount; i++)
{
float t = i/(positionCount - 1f);
Quaternion rotation = Quaternion.Lerp(fromRotation, toRotation, t);
Vector3 point = rotation*aDirection*sphereRadius;
lineRenderer.SetPosition(i, point);
}
}
}