Sfoglia il codice sorgente

Merge class_name docs from scripting_continued.rst into gdscript docs

Nathan Lovato 4 anni fa
parent
commit
7e7df1cc03

+ 1 - 1
getting_started/step_by_step/resources.rst

@@ -190,7 +190,7 @@ those values and saves the resource, the Inspector serializes the custom propert
 too! To save a resource from the Inspector, click the Inspector's tools menu (top right),
 and select "Save" or "Save As...".
 
-If the script's language supports :ref:`script classes <doc_scripting_continued_class_name>`,
+If the script's language supports :ref:`script classes <doc_gdscript_basics_class_name>`,
 then it streamlines the process. Defining a name for your script alone will add it to
 the Inspector's creation dialog. This will auto-add your script to the Resource
 object you create.

+ 2 - 43
getting_started/step_by_step/scripting_continued.rst

@@ -5,12 +5,9 @@ Scripting (continued)
 Notifications
 -------------
 
-Godot has a system of notifications. These are usually not needed for
+Godot has a low-level notifications system. You don't  are usually not needed for
 scripting, as it's too low-level and virtual functions are provided for
-most of them. It's just good to know they exist. For example,
-you may add an
-:ref:`Object._notification() <class_Object_method__notification>`
-function in your script:
+most of them. You can learn more about how notifications work under the hood in :ref:`doc_godot_notifications`.
 
 .. tabs::
  .. code-tab:: gdscript GDScript
@@ -119,41 +116,3 @@ follows, can be applied to nodes:
         base._PhysicsProcess(delta);
     }
 
-As mentioned before, it's better to use these functions instead of
-the notification system.
-
-.. _doc_scripting_continued_class_name:
-
-Register scripts as classes
----------------------------
-
-Godot has a "Script Class" feature to register individual scripts with the
-Editor. By default, you can only access unnamed scripts by loading the file
-directly.
-
-You can name a script and register it as a type in the editor with the
-``class_name`` keyword followed by the class's name. You may add a comma and an
-optional path to an image to use as an icon. You will then find your new type in
-the Node or Resource creation dialog.
-
-.. tabs::
- .. code-tab:: gdscript GDScript
-
-    extends Node
-
-    # Declare the class name here
-    class_name ScriptName, "res://path/to/optional/icon.svg"
-
-    func _ready():
-        var this = ScriptName           # reference to the script
-        var cppNode = MyCppNode.new()   # new instance of a class named MyCppNode
-
-        cppNode.queue_free()
-
-.. image:: img/script_class_nativescript_example.png
-
-
-.. warning:: In Godot 3.1:
-
-            - Only GDScript and NativeScript, i.e., C++ and other GDNative-powered languages, can register scripts.
-            - Only GDScript creates global variables for each named script.

+ 1 - 1
tutorials/best_practices/autoloads_versus_internal_nodes.rst

@@ -68,7 +68,7 @@ or data across many scenes.
 
 In the case of functions, you can create a new type of ``Node`` that provides
 that feature for an individual scene using the :ref:`class_name
-<doc_scripting_continued_class_name>` keyword in GDScript.
+<doc_gdscript_basics_class_name>` keyword in GDScript.
 
 When it comes to data, you can either:
 

+ 1 - 1
tutorials/best_practices/scenes_versus_scripts.rst

@@ -112,7 +112,7 @@ There are two systems for registering types...
 
    - Set up using :ref:`EditorPlugin.add_custom_type <class_EditorPlugin_method_add_custom_type>`.
 
-- :ref:`Script Classes <doc_scripting_continued_class_name>`
+- :ref:`Script Classes <doc_gdscript_basics_class_name>`
 
    - Editor and runtime accessible.
 

+ 1 - 1
tutorials/plugins/editor/making_plugins.rst

@@ -137,7 +137,7 @@ custom behavior.
 
   Nodes added via an EditorPlugin are "CustomType" nodes. While they work
   with any scripting language, they have fewer features than
-  :ref:`the Script Class system <doc_scripting_continued_class_name>`. If you
+  :ref:`the Script Class system <doc_gdscript_basics_class_name>`. If you
   are writing GDScript or NativeScript, we recommend using Script Classes instead.
 
 To create a new node type, you can use the function

+ 5 - 2
tutorials/scripting/gdscript/gdscript_basics.rst

@@ -1190,8 +1190,6 @@ There are 6 pattern types:
             "Sword", "Splash potion", "Fist":
                 print("Yep, you've taken damage")
 
-
-
 Classes
 ~~~~~~~
 
@@ -1208,6 +1206,11 @@ path. For example, if you name a script file ``character.gd``::
    var Character = load("res://path/to/character.gd")
    var character_node = Character.new()
 
+.. _doc_gdscript_basics_class_name:
+
+Registering named classes
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
 Instead, you can give your class a name to register it as a new type in Godot's
 editor. For that, you use the ``class_name`` keyword. You can optionally use
 the ``@icon`` annotation with a path to an image, to use it as an icon. Your

+ 1 - 1
tutorials/scripting/gdscript/static_typing.rst

@@ -107,7 +107,7 @@ Currently you can use three types of… types:
 1. :ref:`Built-in <doc_gdscript_builtin_types>`
 2. Core classes and nodes (``Object``, ``Node``, ``Area2D``,
    ``Camera2D``, etc.)
-3. Your own, custom classes. Look at the new :ref:`class_name <doc_scripting_continued_class_name>`
+3. Your own, custom classes. Look at the new :ref:`class_name <doc_gdscript_basics_class_name>`
    feature to register types in the editor.
 
 .. note::