Created
January 16, 2022 20:01
-
-
Save farukcan/2b018fea70fea9fbbe829bb3b5c807d7 to your computer and use it in GitHub Desktop.
Unity, Sync children of two objects with same name
This file contains 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
// 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