Skip to content

Instantly share code, notes, and snippets.

@farukcan
Created January 16, 2022 20:01
Show Gist options
  • Save farukcan/2b018fea70fea9fbbe829bb3b5c807d7 to your computer and use it in GitHub Desktop.
Save farukcan/2b018fea70fea9fbbe829bb3b5c807d7 to your computer and use it in GitHub Desktop.
Unity, Sync children of two objects with same name
// Author: github.com/farukcan
// Usage :
// Add 'Child Selector' to objects these you want to sync
// childSelectorSync.Sync();
// This command will sync children of two objects with same name
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChildSelectorSync : MonoBehaviour
{
public ChildSelector source;
public ChildSelector target;
public void Sync()
{
foreach (Transform child in source.transform)
{
if (child.gameObject.activeSelf)
{
target.Select(child.gameObject.name);
return;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment