godot-proposals
godot-proposals copied to clipboard
Asset Protection: Shared Libraries as .pck files with Public Method Definitions
Describe the project you are working on
I am developing premium assets for the Godot Asset Library for game developers. it is difficult to share and sell these assets without risking someone copying your source code. This makes it hard to monetize from the assets without risking theft.
Describe the problem or limitation you are having in your project
Right now, the lack of code protection makes it risky for developers like me to share and sell assets without a way to secure our code, others could easily copy and redistribute it, making it hard to earn money for our hard work. This also discourages people from creating advanced tools for Godot, which limits what everyone can achieve with the engine.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
- .pck as a Safe Container: You put your valuable code inside a protected .pck file.
- Headers as Instructions: Like a user manual, you include clear instructions (similar to how it's done in programming languages like C# and C++) that show others how to use your asset without revealing the code itself.
- The important parts of your code would be hidden inside the protected .pck file. Others could use your asset in their games, but they couldn't just copy and paste your hard work.
- You'd mark the parts of your code that others need to use (for example in the top of the script to use '@export_header').
- Better asset protection to help more developers to monetize without risking theft or others copying and modifying and reselling their code.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
My proposal is adding a new export option in the project export settings to export as .pck shared library.
You'd use the @export_header keyword in the top of the file you want other developers to access. These marked elements become the "public interface" of your asset – they're documented and usable, but the actual code implementation is hidden. The shared library can be loaded in compile time and runtime.
# scriptExample.gd
@export_header
extends Node2D
class_name script_example
##This func will increment any param by one
func increment(param : int ) -> int:
return param +=1
Usage:
# main.gd
extends Control
var runtime_loaded_asset : script_example = load("res://MyAwesomeAsset.pck").new() #during runtime
var compiletime_loaded_asset : script_example = preload("res://MyAwesomeAsset.pck").new() #during compiletime
# They can call your public function,
# but they can't see the code inside!
func _ready() -> void:
var num : int = runtime_loaded_asset.increment(2)
print(num) # Prints 3
num = compiletime_loaded_asset.increment(5)
print(num) # Prints 6
If this enhancement will not be used often, can it be worked around with a few lines of script?
Here's the problem, gdscript is designed to be easy to understand. Even if you try to hide it, it sitll can figure it out. It's also tricky because Godot doesn't currently have a good way to package up your code so that people can use it without being able to see all the details. While asset creators might try to share their GDScript code with a hope others won't modify, resell, or steal it, this could be a solution. .pck file format doesn't have a built-in way to separate the parts of your code you want to share from the parts you need to keep secure. This issue can be solved by a builtin feature that gives asset creators to secure their assets and earn from it.
Is there a reason why this should be core and not an add-on in the asset library?
To properly protect code, we need to change how Godot itself handles and runs that code. An add-on can't change those fundamental parts of the engine. This isn't just about a few people selling assets. A reliable way to share code and montize from assets safely which can contribute to godot ecosystem. More people creating and earning means the better the tools.