Пример #1
0
        /// <summary>
        /// Creates drawables for a <see cref="CubismModel"/>.
        /// </summary>
        /// <param name="unmanagedModel">Handle to unmanaged model.</param>
        /// <returns>Drawables root.</returns>
        internal static GameObject CreateDrawables(CubismUnmanagedModel unmanagedModel)
        {
            var root = new GameObject("Drawables");


            // Create drawables.
            var unmanagedDrawables = unmanagedModel.Drawables;
            var buffer             = new CubismDrawable[unmanagedDrawables.Count];


            for (var i = 0; i < buffer.Length; ++i)
            {
                var proxy = new GameObject();


                buffer[i] = proxy.AddComponent <CubismDrawable>();


                buffer[i].transform.SetParent(root.transform);
                buffer[i].Reset(unmanagedModel, i);
            }


            return(root);
        }
Пример #2
0
        /// <summary>
        /// Initializes instance for first use.
        /// </summary>
        /// <param name="moc">Moc to instantiate from.</param>
        private void Reset(CubismMoc moc)
        {
            Moc           = moc;
            name          = moc.name;
            TaskableModel = new CubismTaskableModel(moc);


            // Create and initialize proxies.
            var parameters = CubismParameter.CreateParameters(TaskableModel.UnmanagedModel);
            var parts      = CubismPart.CreateParts(TaskableModel.UnmanagedModel);
            var drawables  = CubismDrawable.CreateDrawables(TaskableModel.UnmanagedModel);


            parameters.transform.SetParent(transform);
            parts.transform.SetParent(transform);
            drawables.transform.SetParent(transform);


            Parameters = parameters.GetComponentsInChildren <CubismParameter>();
            Parts      = parts.GetComponentsInChildren <CubismPart>();
            Drawables  = drawables.GetComponentsInChildren <CubismDrawable>();
        }