Created
March 19, 2025 01:51
-
-
Save movitto/42094865c769afa3ebd7ffca92de7541 to your computer and use it in GitHub Desktop.
Populates Unity Instant Timelapse Controller Screenshot A Day with the selected gameobject's children
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.SceneManagement; | |
using UnityEditor; | |
using System.Collections.Generic; | |
using System.Linq; | |
using com.cyborgAssets.screenshotADay; | |
namespace DevNullProd{ | |
namespace TheLongestTale{ | |
namespace Editor{ | |
// Finds and populates an instant timealpse controller | |
// with direct children of the selected gameobjects | |
public class PopulateInstantTimelapse { | |
private static InstantTimelapseController_ScreenshotADay ITC{ | |
get{ | |
return SceneManager.GetActiveScene().GetRootGameObjects() | |
.First(go => go.GetComponent<InstantTimelapseController_ScreenshotADay>() != null) | |
.GetComponent<InstantTimelapseController_ScreenshotADay>(); | |
} | |
} | |
[MenuItem("Tools/DevNullProd/Populate Instant Timelapse")] | |
public static void DoExtract(){ | |
InstantTimelapseController_ScreenshotADay itc = ITC; | |
if(itc.groups == null) | |
itc.groups = new List<InstantTimelapseData_ScreenshotADay>(); | |
if(itc.groups.Count == 0) | |
itc.groups.Add(new InstantTimelapseData_ScreenshotADay()); | |
InstantTimelapseData_ScreenshotADay itcd = itc.groups[0]; | |
if(itcd.gameObjects == null) | |
itcd.gameObjects = new List<GameObject>(); | |
foreach(Object obj in Selection.objects){ | |
GameObject go = (GameObject)obj; | |
foreach(Transform child in go.transform) | |
itcd.gameObjects.Add(child.gameObject); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment