using UnityEngine;
public class Test : MonoBehaviour
{
public void SetQualityLevel(int index)
{
QualitySettings.SetQualityLevel(index, true);
}
}
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof (LineRenderer))]
public class LineRendererTest : MonoBehaviour
{
public List<Transform> points = new List<Transform>();
private LineRenderer lineRenderer;
private void Awake()
{
lineRenderer = GetComponent<LineRenderer>();
}
private void Update()
{
for (int i = 0; i < points.Count; i++)
{
var point = points[i];
lineRenderer.SetPosition(i, point.position);
}
}
}
using UnityEditor;
using UnityEngine;
public static class Readonly
{
[MenuItem("GameObject/Set readonly")]
public static void SetReadonly()
{
foreach (var o in Selection.objects)
{
o.hideFlags = HideFlags.NotEditable;
}
}
[MenuItem("GameObject/Set writable")]
public static void SetWritable()
{
foreach (var o in Selection.objects)
{
o.hideFlags = HideFlags.None;
}
}
}
public class AsteroidsController : MonoBehaviour
{
public GameObject asteroidFieldPrefab;
private GameObject[] asteroids;
public void SpawnAsteroids(GameObject star, AsteroidBelt[] asteroidBelts)
{
asteroids = new GameObject[asteroidBelts.Length];
for (int i = 0; i < asteroids.Length; i++)
{
AsteroidBelt ast = asteroidBelts[i];
asteroids[i] = (GameObject) Instantiate(asteroidFieldPrefab, new Vector3(0, 0, 0), Quaternion.identity);
//Поскольку система изначально имеет радиус 1, она начинает спавнить астероиды внутри звезды. Не надо так
asteroids[i].SetActive(false);
asteroids[i].name = ast.name;
asteroids[i].transform.localScale *= Units_class.MetersToUnityUnits(ast.radius);
//А теперь надо
asteroids[i].SetActive(true);
AsteroidFieldOrbiter_script orbScript = asteroids[i].GetComponent<AsteroidFieldOrbiter_script>();
orbScript.astdField = ast;
orbScript.star = star;
orbScript.SetStartPosit();
}
}
}