Browse Source

Merge branch 'master' into diagnostics-and-blog-post

Vaclav Elias 2 years ago
parent
commit
a9667cae57

+ 90 - 0
.github/workflows/stride-docs-release-azure.yml

@@ -0,0 +1,90 @@
+# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
+# More GitHub Actions for Azure: https://github.com/Azure/actions
+
+name: Build Stride Docs for Azure Web App Release 🚀
+
+on:
+  push:
+    branches:
+      - release
+    paths-ignore:
+      - 'README.md'
+      - 'Stride.Docs.sln'
+      - 'BuildDocs.ps1'
+      - 'wiki/**'
+      - .gitignore
+      - '.github/**'
+  workflow_dispatch:
+
+jobs:
+  build:
+    if: github.repository == 'stride3d/stride-docs'
+    runs-on: windows-2022
+
+    steps:
+    - name: Dotnet Setup
+      uses: actions/setup-dotnet@v3
+      with:
+        dotnet-version: 6.x
+
+    - name: Checkout Stride Docs
+      uses: actions/checkout@v3
+      with:
+        path: stride-docs
+        lfs: true
+
+    - name: Checkout Stride (note the LFS)
+      uses: actions/checkout@v3
+      with:
+        repository: stride3d/stride
+        token: ${{ secrets.GITHUB_TOKEN }}
+        path: stride
+        lfs: true
+
+    - name: Install DocFX
+      # This installs the latest version of DocFX and may introduce breaking changes.
+      # run: dotnet tool update -g docfx
+      # This installs a specific, tested version of DocFX.
+      run: dotnet tool update -g docfx --version 2.70.3
+
+    - name: Build documentation
+      run: ./build-all.bat
+      working-directory: stride-docs
+
+    - name: Compress artifact
+      run: 7z a -r DocFX-app.zip ./stride-docs/_site/*
+
+    - name: Upload artifact for deployment job
+      uses: actions/upload-artifact@v3
+      with:
+        name: DocFX-app
+        path: DocFX-app.zip
+
+  deploy:
+    if: github.repository == 'stride3d/stride-docs'
+    runs-on: windows-2022
+    needs: build
+    environment:
+      name: 'Production'
+      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
+
+    steps:
+      - name: Download artifact from build job
+        uses: actions/download-artifact@v3
+        with:
+          name: DocFX-app
+
+      # - name: List current directory
+      #   run: ls
+
+      - name: Decompress artifact
+        run: 7z x DocFX-app.zip "-o./stride-docs/_site"
+
+      - name: Deploy to Azure Web App
+        id: deploy-to-webapp
+        uses: azure/webapps-deploy@v2
+        with:
+          app-name: 'stride-doc'
+          slot-name: 'Production'
+          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_4803638D673FA67D0C8650F34C4FA9D1 }}
+          package: ./stride-docs/_site

+ 21 - 6
en/manual/game-studio/prefabs/use-prefabs.md

@@ -24,9 +24,9 @@ If you don't want to create a parent entity with the prefab, hold **Alt** when y
 
 In this case, a parent entity is unnecessary. Instead, you can create several instances of the prefab, then re-arrange their individual crate entities to create the effect you need.
 
-| Relative positions maintained                   | Relative positions ignored
-|-------------------------------------------------|
-| ![Boxes duplicated](media/boxes-duplicated.jpg) | ![Boxes duplicated](media/boxes-random.jpg)
+| Relative positions maintained                   | Relative positions ignored                  |
+|-------------------------------------------------|---------------------------------------------|
+| ![Boxes duplicated](media/boxes-duplicated.jpg) | ![Boxes duplicated](media/boxes-random.jpg) |
 
 ## Break link to prefab
 
@@ -40,8 +40,23 @@ To do this, in the **Scene Editor**, right-click a child entity or entities and
 
 To use prefabs at runtime, you need to instantiate them and then add them to the scene in code.
 
+```cs
+public class SpawnPrefabOnStart : StartupScript
+{
+    public Prefab MyPrefab { get; init; } // init here prevents other scripts from changing this property
+    
+    public override void Start()
+    {
+        // A prefab may contain multiple entities
+        var entities = MyPrefab.Instantiate();
+        // Adding them to the scene this entity is on
+        Entity.Scene.Entities.AddRange(entities);
+    }
+}
+```
+
 > [!Note]
-> Just calling `Instantiate()` isn't enough to add a prefab instance to the scene. You also need to use `Add()`. For example, if your prefab contains a model, the model is invisible until you add the prefab instance. Likewise, if your prefab contains a script, the script won't work until you add the prefab instance.
+> `Instantiate()` by itself isn't enough to add a prefab instance to the scene. You also need to `Add()` or `AddRange()` them to a scene . For example, if your prefab contains a model, the model is invisible until you add the prefab instance. Likewise, if your prefab contains a script, the script won't work until you add the prefab instance.
 
 If you have a prefab named *MyBulletPrefab* in the root folder of your project, you can instantiate and add it with the following code:
 
@@ -58,7 +73,7 @@ private void InstantiateBulletPrefab()
     // Change the X coordinate
     bullet.Transform.Position.X = 20.0f;
 
-    // Add the bullet to the scene
+    // Adding just the bullet to the root scene
     SceneSystem.SceneInstance.RootScene.Entities.Add(bullet);
 }
 ```
@@ -74,4 +89,4 @@ private void InstantiateBulletPrefab()
 * [Edit prefabs](edit-prefabs.md)
 * [Nested prefabs](nested-prefabs.md)
 * [Override prefab properties](override-prefab-properties.md)
-* [Prefab models](prefab-models.md)
+* [Prefab models](prefab-models.md)