ResourcesSampleExtension.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. using System.IO;
  2. using PixiEditor.Extensions.Sdk;
  3. namespace ResourcesSample;
  4. public class ResourcesSampleExtension : PixiEditorExtension
  5. {
  6. /// <summary>
  7. /// This method is called when extension is loaded.
  8. /// All extensions are first loaded and then initialized. This method is called before <see cref="OnInitialized"/>.
  9. /// </summary>
  10. public override void OnLoaded()
  11. {
  12. }
  13. /// <summary>
  14. /// This method is called when extension is initialized. After this method is called, you can use Api property to access PixiEditor API.
  15. /// </summary>
  16. public override void OnInitialized()
  17. {
  18. // By default, you can't access any files from the file system, however you can access files from the Resources folder.
  19. // This folder contains files that you put in the Resources folder in the extension project.
  20. Api.Logger.Log(File.ReadAllText("Resources/ExampleFile.txt"));
  21. Api.Logger.Log("Writing to file...");
  22. File.WriteAllText("Resources/ExampleFile.txt", "Hello from extension!");
  23. Api.Logger.Log(File.ReadAllText("Resources/ExampleFile.txt"));
  24. }
  25. }