- Home /
The question is answered, right answer was accepted
Can I access components scripts?
What I mean is, can I see the script for the Particle System for instance?
Answer by tr1stan · Aug 15, 2012 at 01:25 PM
The particle system attached to a gameobject is a build-in component of unity, just like a transform, an audio source or a camera component. There's no way you can browse and edit the source script of the particle system.
Thank you for understanding my question. Why did Unity blocked it? and how come I could see some of their scripts? (like shaders and etc)
They block it because it is what makes Unity, if how it works would be open source, anyone with enough knowledge could simply use their codes and build his own engine. They protect their years of research and money spent this way. The shaders are probably available since most of them are widely known and available online. I may be wrong though but if I spent years and money developing a tool, I would make sure it does not slip through my fingers after 3 months.
To me, the particle system of unity and any other game engine is more likely artist driven. There's not much advantage you can take by using code over GUI. In unity, creating good particle effect is all about how to tweak the params in GUI and making good texture assets.
And as a close-source commercial game engine, you can't access any actual source from unity editor. All codes (except shaders) you see in unity editor either build-in or created on your own are interpreted scripts that helps you to write game logic. So unity make script api only if it's absolutely necessary, which I believe it's not for the particle system.
Answer by Wekthor · Aug 15, 2012 at 03:46 PM
it should be something like this :
ParticleSystem particleSystemComponent;
void Start()
{
paricleSystemComponent = this.tranform.GetComponent<ParticleSystem>();
particleSystemComponent.loop = true; //for example
}
Answer by poncho · Aug 15, 2012 at 03:09 PM
you gan get the public components of any game object ie,
GameObject myPlayer;
myPlayer = GameObject.find("myPlayerGO");
myPlayer.getComponent<rigidbody>().useGravity = false
myPlayer.getComponent<oneOfMyPublicScripts>().moving = false;
hope you get the idea