void UpdateClones() { if (lastSourceMode != sourceMode) { lastSourceMode = sourceMode; forceUpdateClones = true; } if (clones.Length == (int)n && !forceUpdateClones) { return; } sources.RemoveAll(source => source == null); for (int i = transform.childCount - 1; i >= 0; i--) { DestroyImmediate(transform.GetChild(i).gameObject); } sourcesPSR.Clear(); foreach (var source in sources) { sourcesPSR.Add(PSR.from(source)); } clones = new GameObject[(int)n]; clonesSourceRef = new GameObject[(int)n]; for (int i = 0; i < n; i++) { GameObject source = GetSource(i); clonesSourceRef [i] = source; clones [i] = Instantiate(source); clones [i].transform.SetParent(transform); } forceUpdateClones = false; }
public static PSR from(GameObject go, bool global = true) { return(PSR.from(go.transform, global)); }