Ejemplo n.º 1
0
 /// <summary>
 /// <para>
 /// Attach multipe <see cref="Morph"/>s into the current <see cref="rootObject"/> and all it's children. This means
 /// if Hair, Clothing, Etc. are attached they will have the morphs attached as well.
 /// </para>
 /// <para>
 /// Method can be done Async wiht optional CallBack.
 /// </para>
 /// </summary>
 /// <param name="morphs"><see cref="Morph"/>s to be attached. </param>
 public void AttachMorphs(Morph[] morphs, bool refresh = false, bool async = false, StreamingMorphs.OnPostInjectionMorphs callback = null)
 {
     if (morphs.Length <= 0)
     {
         return;
     }
     string[] morphNames = new string[morphs.Length];
     for (int i = 0; i < morphs.Length; i++)
     {
         Morph m = morphs[i];
         morphNames[i] = m.localName;
     }
     AttachMorphs(morphNames, refresh, async, callback);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// <para>
        /// Attach multipe <see cref="Morph"/>s from a list of morph names into the current <see cref="rootObject"/> and all it's children. This means
        /// if Hair, Clothing, Etc. are attached they will have the morphs attached as well.
        /// </para>
        /// <para>
        /// Method can be done Async wiht optional CallBack.
        /// </para>
        /// </summary>
        /// <param name="morphNames">localNames of the morphs to attach </param>
        public void AttachMorphs(string[] morphNames, bool refresh = false, bool async = false, StreamingMorphs.OnPostInjectionMorphs callback = null)
        {
            StreamingMorphs.LoadMainThreadAssetPaths();
            //do nothing if we're empty
            if (morphNames.Length <= 0)
            {
                return;
            }

            List <string> keepNames = new List <string>();

            //we need to update the morph groups now...
            foreach (string morphName in morphNames)
            {
                Morph m;
                if (morphLookup.TryGetValue(morphName, out m))
                {
                    //add this morph to the Attached list if not already in there
                    if (!morphStateGroups["Attached"].Contains(m))
                    {
                        morphStateGroups["Attached"].Add(m);
                        keepNames.Add(morphName);
                    }

                    //remove this one from available since we're installing it
                    morphStateGroups["Available"].Remove(m); //will return false, not throw, if the kye isn't found

                    m.attached = true;
                }
            }

            if (!async)
            {
                //tell our streamingblendshapes object to add the blendshape into our mesh(es), this is recursive (so things like hair/clothes/etc will get the morph as well as the base figure)
                streamingMorphs.InjectMorphNamesIntoFigure(rootObject, (refresh ? morphNames : keepNames.ToArray()), true);
            }
            else
            {
                streamingMorphs.InjectMorphNamesIntoFigureAsync(rootObject, (refresh ? morphNames : keepNames.ToArray()), true, callback);
            }
        }