Is there a way to change the color of a Halo in Code? There doesn't seem to be a Halo-Class, which is strange. I thought every component basically was a class deriving from MonoBehaviour.
Меняет Цвет Halo - по крайней мере оно его находит))))) вообще круто так долго искал это…
UnityEditor.SerializedObject halo = new UnityEditor.SerializedObject(coll.gameObject.GetComponent("Halo"));
or/или
using UnityEditor;
...
SerializedObject halo = new SerializedObject(coll.gameObject.GetComponent("Halo"));
halo.FindProperty("m_Size").floatValue += 3f;
halo.FindProperty("m_Enabled").boolValue = true;
halo.FindProperty("m_Color").colorValue = Color.blue;
halo.ApplyModifiedProperties();
dude you can use point light and enable the draw halo and at runtime you can change the color and the range(size of the halo), and if you dont want the light to effect the the environment you can play with layers.
cheers
There isn't a way, no....Halo is a built-in component that isn't exposed to scripting unfortunately.
halo uses a texture that you define in render settings and unfortunately just it's size is scriptable in RenderSettings class. you can not change the texture and it's color. just the size can be changed. request this feature in feedback. hopefully others will vote for it and i think it's not hard to implement. render settings are per scene and you can define different halos for different scenes. built in components are in a lower level than components that you make. some of their properties are exposed to scripting engine and some of them are not. it's good to have all of them exposed. one can change halos to show the weather changes and the amount of dust in the air or ...
i guess only way is changing color of the light
Halo seems very basic. Most of what it does can be achieved by adding your own camera-facing plane with you own unique blob on it.
Flares on the other hand are cool
Update :: this does not work outside of the development environment. Prefabs are the correct approach when working with these types of components.
This is possible at least in development environment. (JS example):
var halo = SerializedObject(GetComponent("Halo"));
halo.FindProperty("m_Size").intValue = 10;
halo.FindProperty("m_Color").colorValue = Color.blue;
halo.ApplyModifiedProperties();
Will do it.
Not sure of portability or other concerns though. This has only been tested in development. This seems to work to access other useful things such as parts of the new particle emission system, such as direction and type when generated in script.
If you want to use this with other components you can check their protected properties to modify with this (JS example):
var so = SerializedObject(GetComponent(targetComponent));
var it: SerializedProperty = so.GetIterator();
while (it.Next(true)) {
Debug.Log (it.propertyPath);
}
There is a way to replace halo with a point light. Set light range equal to (halo size * 2), intensity/multiplier to 1, culling mask to “nothing” (very important as others will cause serious perf regression if there are a lot of such components) and render mode to “important”. This way you can modify your range/color from the script.