The Swartz-Manning’s first exhibit will provide a detailed history of Aaron Swartz Day. https://www.aaronswartzday.org/vr
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.

RenameNewObjects.cs 982B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * This script demonstrates how one might use the OnproBuilderObjectCreated delegate.
  3. */
  4. // Uncomment this line to enable this script.
  5. // #define PROBUILDER_API_EXAMPLE
  6. #if PROBUILDER_API_EXAMPLE
  7. using UnityEngine;
  8. using UnityEditor;
  9. using System.Collections;
  10. using ProBuilder2.Common;
  11. using ProBuilder2.EditorCommon;
  12. [InitializeOnLoad]
  13. public class RenameNewObjects : Editor
  14. {
  15. /**
  16. * Static constructor is called and subscribes to the OnProBuilderObjectCreated delegate.
  17. */
  18. static RenameNewObjects()
  19. {
  20. pb_EditorUtility.AddOnObjectCreatedListener(OnProBuilderObjectCreated);
  21. }
  22. ~RenameNewObjects()
  23. {
  24. pb_EditorUtility.RemoveOnObjectCreatedListener(OnProBuilderObjectCreated);
  25. }
  26. /**
  27. * When a new object is created this function is called with a reference to the pb_Object
  28. * last built.
  29. */
  30. static void OnProBuilderObjectCreated(pb_Object pb)
  31. {
  32. pb.gameObject.name = string.Format("pb_{0}{1}", pb.gameObject.name, pb.GetInstanceID());
  33. }
  34. }
  35. #endif