Auto-Draggable Variables

I want to be able to drag & drop variables (floats, integers, maybe even classes) in the inspector view. So that if I have FirstScript and SecondScript I could easily drag & drop variables between them so that they can change each others’ data. I need this to create more modular workflow.

I know that ScriptableObjects allow similar functionality but I need to create them manually through Create button in Inspector. Instead I want this to happen automatically.

This should look somthing like scripts below. So that I could drag the original_float to float_to_change field right in the Inspector.

// First Component

public class FirstScript : MonoBehaviour
{
    public DraggableFloat original_float = 5.0f;
}

// SecondComponent

public class SecondScript: MonoBehaviour
{
    public DraggableFloat float_to_change;

    public void ChangeFloat()
    {
        // The value of original_float is changed through reference
        float_to_change += 10.0f;
    }
}

But you can instantiate ScriptableObjects as well. And potentially saving them afterwards to the project.

If you want to go really difficult path, you could implement a PropertyAttribute, then PropertyDrawer that adds some extra functionality to the editor.

That way you’ll be able to write a drag & drop functionality without creating extra data classes.

Yes, but it won’t be possible to share the value between scripts so OP definitely needs a custom class. You can create a class what behaves just like float variable and use it along with @VergilUa advice, it should work.
But for me those efforst looks like just waste of time.