Ei kuvausta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SubTarget.cs 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UIElements;
  5. using UnityEditor.ShaderGraph.Serialization;
  6. namespace UnityEditor.ShaderGraph
  7. {
  8. [Serializable, GenerationAPI] // TODO: Public
  9. internal abstract class SubTarget : JsonObject
  10. {
  11. internal abstract Type targetType { get; }
  12. internal Target target { get; set; }
  13. public string displayName { get; set; }
  14. public bool isHidden { get; set; }
  15. public abstract bool IsActive();
  16. public abstract void Setup(ref TargetSetupContext context);
  17. public abstract void GetFields(ref TargetFieldContext context);
  18. public abstract void GetActiveBlocks(ref TargetActiveBlockContext context);
  19. public abstract void GetPropertiesGUI(ref TargetPropertyGUIContext context, Action onChange, Action<String> registerUndo);
  20. public virtual void CollectShaderProperties(PropertyCollector collector, GenerationMode generationMode) { }
  21. public virtual void ProcessPreviewMaterial(Material material) { }
  22. public virtual object saveContext => null;
  23. public virtual bool IsNodeAllowedBySubTarget(Type nodeType) => true;
  24. // Call after SubTarget parent Target has been deserialized and Subtarget.target has been set to a non-null value.
  25. internal virtual void OnAfterParentTargetDeserialized() { }
  26. }
  27. [GenerationAPI] // TODO: Public
  28. internal abstract class SubTarget<T> : SubTarget where T : Target
  29. {
  30. internal override Type targetType => typeof(T);
  31. public new T target
  32. {
  33. get => base.target as T;
  34. set => base.target = value;
  35. }
  36. }
  37. }