/*
         * Given a non empty array of GameObject and an AssetLoaderController, spawn all the avators available
         * and uses the array to get a reference to them. It is possibile to set rotation,position and a parent.
         * Umas are generated according the array of names given in input.
         * */
        public static GameObject[] SpawnAllAvator(GameObject[] umasSet,
                                                  AssetLoaderController _assetLoaderController,
                                                  string[] arrayOfNames,
                                                  Transform _parent,
                                                  Vector3 umasPosition,
                                                  Quaternion umasRotation,
                                                  Action <UMAData> onCharacterCreatedCallbac = null
                                                  )
        {
            for (int x = 0; x < umasSet.Length; x++)
            {
                umasSet[x] = new GameObject();
                umasSet[x].gameObject.AddComponent <UMADynamicAvatar>();
                umasSet[x].gameObject.name = arrayOfNames[x];

                umasSet[x] = createUMAAvator(_assetLoaderController,
                                             arrayOfNames[x],
                                             umasSet[x].gameObject.GetComponent <UMADynamicAvatar>(),
                                             onCharacterCreatedCallbac);

                if (_parent != null)
                {
                    umasSet[x].transform.parent = _parent;
                }
                umasSet[x].transform.position = umasPosition;
                umasSet[x].transform.rotation = umasRotation;
            }
            return(umasSet);
        }
 private void Awake()
 {
     AssetLoaderController = GetComponent <AssetLoaderController>();
     AssetLoaderController.CacheAllUMA(CommonNames.assetsNameStreamingFolder);
     TowersController        = GetComponent <TowersController>();
     ServerNetworkController = GetComponent <ServerNetworkController>();
 }
        private void Awake()
        {
            ClientNetworkController = GetComponent <ClientNetworkController>();
            ConnectionInfo          = GetComponent <ConnectionInfo>();
            AssetLoaderController   = GetComponent <AssetLoaderController>();

            AssetLoaderController.CacheAllUMA(CommonNames.assetsNameStreamingFolder);
            ConnectionInfo.SetConnectionInfo();
            ClientNetworkController.StartCustomNetworkController(ConnectionInfo);
        }
        /**
         * Given an AssetLoaderController in input,a UMA avator's name and a UMADynamicAvator
         * create and spawn a new uma avator. It is possible to pass also a callback
         * that it's executed after the uma avator is created.
         * */
        public static GameObject createUMAAvator(AssetLoaderController assetLoaderController,
                                                 string umaAvatorName,
                                                 UMADynamicAvatar umaDynamicAvator,
                                                 Action <UMAData> onCharacterCreatedCallback = null)
        {
            GameObject thisUma = null;

            if (assetLoaderController != null && umaAvatorName != null &&
                umaDynamicAvator != null)
            {
                //Set/spawn a UMA Avator
                thisUma = umaDynamicAvator.gameObject;
                UMADynamicAvatar thisUmaDynamicAvator = thisUma.GetComponent <UMADynamicAvatar>();

                thisUmaDynamicAvator.context      = assetLoaderController.context;
                thisUmaDynamicAvator.umaGenerator = assetLoaderController.generator;
                thisUmaDynamicAvator.loadOnStart  = false;
                thisUmaDynamicAvator.Initialize();
                thisUmaDynamicAvator.animationController = assetLoaderController.thirdPersonController;
                UMATextRecipe recipe = assetLoaderController.umaCharactersTemplates[umaAvatorName];
                thisUmaDynamicAvator.Load(recipe);

                if (onCharacterCreatedCallback != null)
                {
                    thisUma.GetComponent <UMAData>().OnCharacterCreated += onCharacterCreatedCallback;
                }
            }
            else
            {
                string partOfTheError = "given in input is null";
                if (assetLoaderController == null)
                {
                    throw new System.ArgumentException("AssetLoader " + partOfTheError);
                }
                else if (umaAvatorName == null)
                {
                    throw new System.ArgumentException("UMA's avator name " + partOfTheError);
                }
                else if (umaDynamicAvator == null)
                {
                    throw new System.ArgumentException("DyanamicAvator " + partOfTheError);
                }
            }
            return(thisUma);
        }
 private void Awake()
 {
     AssetLoaderController = GetComponent <AssetLoaderController>();
     createdUmas           = new GameObject[CommonNames.avators.Length];
 }