Beispiel #1
0
        public void GenerateVAT(string targetName, int renderersCount, float duration, int frames, Bounds bounds, Bounds startBounds, List <Vector3>[] renderersPositions, List <Quaternion>[] renderersRotations)
        {
            EnsureFolders();
            if (!_highPrecisionPosition)
            {
                WritePositionsTexture(targetName, renderersCount, frames, bounds, renderersPositions);
            }
            else
            {
                WriteHighPrecisionPositionsTextures(targetName, renderersCount, frames, bounds, renderersPositions);
            }
            WriteRotationsTexture(targetName, renderersCount, frames, renderersRotations);

            VATAnimation vatAnimation = ScriptableObject.CreateInstance <VATAnimation>();

            vatAnimation.Frames                    = frames;
            vatAnimation.Duration                  = duration;
            vatAnimation.BoundsCenter              = bounds.center;
            vatAnimation.BoundsExtents             = bounds.extents;
            vatAnimation.StartBoundsCenter         = startBounds.center;
            vatAnimation.StartBoundsExtents        = startBounds.extents;
            vatAnimation.HighPrecisionPositionMode = _highPrecisionPosition;
            vatAnimation.PartsCount                = renderersCount;
            vatAnimation.PartsIdsInUV3             = vatAnimation.PartsCount > 256;
            if (!_highPrecisionPosition)
            {
                vatAnimation.PositionsTex = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/" + SAVE_FOLDER_TEXTURES + targetName + "_PositionTex.png", typeof(Texture2D));
                SetTextureSettings(vatAnimation.PositionsTex);
            }
            else
            {
                vatAnimation.PositionsTex = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/" + SAVE_FOLDER_TEXTURES + targetName + "_PositionTex.png", typeof(Texture2D));
                SetTextureSettings(vatAnimation.PositionsTex);
                vatAnimation.PositionsTexB = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/" + SAVE_FOLDER_TEXTURES + targetName + "_PositionTexB.png", typeof(Texture2D));
                SetTextureSettings(vatAnimation.PositionsTexB);
            }

            vatAnimation.RotationsTex = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/" + SAVE_FOLDER_TEXTURES + targetName + "_RotationTex.png", typeof(Texture2D));
            SetTextureSettings(vatAnimation.RotationsTex);
            string animationPath = "Assets/" + SAVE_FOLDER + targetName + ".asset";

            AssetDatabase.CreateAsset(vatAnimation, animationPath);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            VATMeshGenerator vatMeshGenerator = new VATMeshGenerator();

            vatMeshGenerator.SetMeshBounds(targetName, bounds);
            vatMeshGenerator.SetAnimationToPrefab(targetName, (VATAnimation)AssetDatabase.LoadAssetAtPath(animationPath, typeof(VATAnimation)));

            Debug.LogError("Generation Finished");
        }
Beispiel #2
0
        public void SetAnimationToPrefab(string targetName, VATAnimation vatAnimation)
        {
            GameObject prefab   = (GameObject)AssetDatabase.LoadAssetAtPath(GetPrefabPath(targetName), typeof(GameObject));
            GameObject instance = PrefabUtility.InstantiatePrefab(prefab) as GameObject;

            instance.GetComponent <VATGPUPlayer>().SetAnimation(vatAnimation);

            PrefabUtility.ApplyPrefabInstance(instance, InteractionMode.AutomatedAction);
            GameObject.Destroy(instance);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            Selection.activeGameObject = prefab;
            EditorGUIUtility.PingObject(prefab);
        }
 public void SetAnimation(VATAnimation vatAnimation)
 {
     _vatAnimation = vatAnimation;
 }