PlayCanvas Editor API Extension

Load as a script extension under Editor in the Asset List. The @namespace link is a sample project.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name        PlayCanvas Editor API Extension
// @name:ja     PlayCanvas Editor API拡張
// @namespace   https://playcanvas.com/editor/scene/1636573
// @match       https://playcanvas.com/editor/scene/*
// @grant       none
// @version     1.0
// @author      yushimatenjin
// @description Load as a script extension under Editor in the Asset List. The @namespace link is a sample project.
// @description:ja 「Assets」→「Editor」ファイルの下にあるスクリプトを拡張機能としてロードします。@namespaceのサンプルプロジェクトを御覧ください。
// @license MIT
// ==/UserScript==


(function() {
  // Assetsのフォルダ一覧からEditor以下のJavaScriptファイルを拡張として読み込みます
  const importExtensionsFromAssets = () => {
    const extentionsFolder = editor.assets.list().find((data) => {
      const { type, name, path } = data.json();
      return type === "folder" && name === "Editor" && path.length === 0;
    });

    if (!extentionsFolder) {
      console.warn("Create an Editor folder in the assets.");
      return;
    }

    const extentions = editor.assets.list().filter((data) => {
      const { path, type } = data.json();
      return path[0] === extentionsFolder.json().id && type === "script";
    });

    extentions.forEach((data) => {
      const { url } = data.json().file;
      var script = document.createElement("script");
      script.src = url;
      console.log(url)
      document.head.appendChild(script);
    });
  };

   editor.on('assets:load', () => importExtensionsFromAssets());
})();