Confused about scripting extended gameobject properties

Hi,

I’m a bit new to scripting in unity and one thing is confusing me. How is it possible to create a script to extend/adapt the object it is attached to? For instance, if I create a slider, how can I change the slider’s properties through scripting?

The same question goes for shader scripting. How is it possible to change the properties of an existing shader, by creating a new script, or perhaps extend the processing of an already existing shader?

It is very clear how to create objects and change their properties. However, not so clear to change properties of an existing object/shader.

Cheers

any1?

It’s not entirely clear to me what you’re asking.

To change an object’s (public) properties, you get a reference to the object, and assign new values to its properties.

Your question seems to confound “change the properties” with “change the code.” A property is a public variable of a class, which can hold a value for any instance of that class. You don’t need to subclass or modify the code to change these values; indeed, that doesn’t make any sense, as the class itself doesn’t have property values; instances do.

Unless by “change the properties” you mean to change what properties are defined (add new properties, rename old properties, etc.). In that case you would indeed need to modify the code, or subclass in the case of adding new properties.

Can you give a more specific example of what you’re trying to accomplish?