Public variables in scripts assets vs attached components

What is the difference between a public field exposed in the Inspector when you click on a script file asset (they are shown right below “ScriptName import settings”) and the same field shown in the Inspector when you drag this script onto a gameobject as a component?

Public name can you can you the options outside of code
this system use i don have samey options all time

for example
if have player speed 15 static
if have player speed 15 Public not static

If I understand the question

The links for anything in the Project file are just possible time-saving shortcuts. They’re the starting values for real scripts, but otherwise don’t mean anything. They can also only be to other assets in the Project folder - they can’t go to anything in a Scene. It’s the same idea as having public int health=100;. 100 is merely the starting Inspector value for fresh copies of the script.


For example, suppose you have a file CatScript. It might have public AudioClip miaoSound; For a shortcut, in Project you could drag the most common miao softMiao1 into it. Then as you drag that cat onto gameObjects, maioSound will be pre-filled with softMiao1. That might save you time. But you can drag any other sound into real cats, which completely replaces it.


In practice, it’s not super-useful. Most scripts in Project will be on prefabs, and those give you a more real-looking copy of the Inspector to fill with starting values (in the Cat example, you wouldn’t be creating gameObjects and dragging cat scripts onto them - you’d make a Cat prefab and make all your real cats with that.)