Example #1
0
        //----------------------------------------------------------------------------------
        private void SampleCaronteFX(GameObject go, out bool isVertexAnimated)
        {
            isVertexAnimated = false;
            if (!go.HasMesh())
            {
                return;
            }

            CRAnimation crAnimation = CarEditorUtils.GetFirstComponentInHierarhcy <CRAnimation>(go);

            if (crAnimation != null)
            {
                listBoneTransformTmp_.Clear();

                crAnimation.LoadAnimation(true);
                crAnimation.SetFrame(0.0f);

                isVertexAnimated = crAnimation.IsVertexAnimated(go);

                SkinnedMeshRenderer smr = go.GetComponent <SkinnedMeshRenderer>();
                if (smr != null)
                {
                    isVertexAnimated = true;
                    SetBonesLocalScateToOneIfApproximatelyZero(smr);
                }

                if (!listCRAnimation_.Contains(crAnimation))
                {
                    listCRAnimation_.Add(crAnimation);
                }
            }
        }
        void Start()
        {
            if (cranimation != null)
            {
                cranimation.LoadAnimation(false);
                cranimation.SetFrame(0f);

                frameRate  = (int)cranimation.Fps;
                frameCount = (int)(cranimation.FrameCount / cranimation.speed);

                Time.captureFramerate = frameRate;
                currentFrame          = 0;
            }
        }
Example #3
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            if (ac_.activeAnimation != ac_.animationLastLoaded_)
            {
                previewInEditor_ = false;
                ac_.CloseAnimation();
            }

            DrawDefaultInspector();
            CRGUIUtils.Splitter();

            /*
             * EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
             * EditorGUI.BeginChangeCheck();
             * previewInEditor_ = EditorGUILayout.Toggle("Preview", previewInEditor_);
             * if ( EditorGUI.EndChangeCheck() )
             * {
             * AnimationPreview( previewInEditor_ );
             * }
             * EditorGUI.EndDisabledGroup();
             */


            bool isPlayingOrPreviewInEditor = EditorApplication.isPlayingOrWillChangePlaymode || previewInEditor_;

            EditorGUI.BeginDisabledGroup(!isPlayingOrPreviewInEditor);
            EditorGUI.BeginChangeCheck();

            editorFrame_ = Mathf.Clamp(ac_.lastReadFrame_, 0, ac_.lastFrame_);
            editorFrame_ = EditorGUILayout.Slider(new GUIContent("Frame"), editorFrame_, ac_.firstFrame_, ac_.lastFrame_);
            if (EditorGUI.EndChangeCheck() && isPlayingOrPreviewInEditor)
            {
                ac_.SetFrame(editorFrame_);
                SceneView.RepaintAll();
            }

            EditorGUI.EndDisabledGroup();
            EditorGUILayout.LabelField(new GUIContent("Time"), new GUIContent(ac_.time_.ToString("F3")));
            EditorGUILayout.LabelField(new GUIContent("Frame Count"), new GUIContent(ac_.frameCount_.ToString()));
            EditorGUILayout.LabelField(new GUIContent("FPS"), new GUIContent(ac_.fps_.ToString()));
            EditorGUILayout.LabelField(new GUIContent("Animation Length"), new GUIContent(ac_.animationLength_.ToString()));
            CRGUIUtils.Splitter();

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);

            CRGUIUtils.Splitter();
            if (GUILayout.Button(new GUIContent("Record screenshots in play mode")))
            {
                MakeCameraScreenshots();
            }

            if (GUILayout.Button(new GUIContent("Remove camera recorder component")))
            {
                RemoveCameraRecorder();
            }

            EditorGUI.EndDisabledGroup();

            Repaint();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            bool isPlayingOrWillChangePlaymode = EditorApplication.isPlayingOrWillChangePlaymode;

            Rect rect = GUILayoutUtility.GetRect(80f, 80f);

            GUI.DrawTexture(rect, ic_logoCaronte_, ScaleMode.ScaleToFit);
            CRGUIUtils.Splitter();

            if (Selection.gameObjects.Length > 1)
            {
                DrawDefaultInspector();
                EditorGUILayout.Space();
                EditorGUI.BeginDisabledGroup(isPlayingOrWillChangePlaymode || ac_.PreviewInEditor || !SystemInfo.supportsComputeShaders);
                DrawDecodeInGPU();
                DrawBufferAllFrames();
                EditorGUI.BeginDisabledGroup(bufferAllFramesProp_.boolValue);
                DrawGPUBufferSize();
                EditorGUI.EndDisabledGroup();
                DrawOverrideShaderForVA();
                DrawUseDoubleSidedShader();
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.Space();
                DrawRecomputeNormals(isPlayingOrWillChangePlaymode);
                serializedObject.ApplyModifiedProperties();
                return;
            }
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            DrawAnimationFileType();
            DrawAnimationFiles();
            CRGUIUtils.Splitter();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            DrawDefaultInspector();
            EditorGUILayout.Space();
            if (CRCompressedPose.CanBeDecompressedByGPU() && !CRCompressedPose.CanBeDecompressedByCPU())
            {
                EditorGUILayout.HelpBox("Only GPU decoding of FiberCompression animations is allowed in this version of the plugin.", MessageType.Info);
            }
            else if (CRCompressedPose.CanBeDecompressedByCPU() && !CRCompressedPose.CanBeDecompressedByGPU())
            {
                EditorGUILayout.HelpBox("Only CPU decoding of FiberCompression animations is allowed in this version of the plugin.", MessageType.Info);
            }
            EditorGUI.BeginDisabledGroup(isPlayingOrWillChangePlaymode || ac_.PreviewInEditor || !SystemInfo.supportsComputeShaders);
            DrawDecodeInGPU();
            DrawBufferAllFrames();
            EditorGUI.EndDisabledGroup();
            EditorGUI.BeginDisabledGroup(!ac_.DecodeInGPU || isPlayingOrWillChangePlaymode || ac_.PreviewInEditor);
            EditorGUI.BeginDisabledGroup(bufferAllFramesProp_.boolValue);
            DrawGPUBufferSize();
            EditorGUI.EndDisabledGroup();
            DrawOverrideShaderForVA();
            DrawUseDoubleSidedShader();
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.Space();
            DrawRecomputeNormals(isPlayingOrWillChangePlaymode);
            serializedObject.ApplyModifiedProperties();
            EditorGUILayout.Space();

            GameObject go               = ac_.gameObject;
            PrefabType pType            = PrefabUtility.GetPrefabType(go);
            bool       isPrefab         = pType == PrefabType.Prefab || pType == PrefabType.PrefabInstance;
            bool       gpuModeRequested = ac_.DecodeInGPU;

            EditorGUI.BeginDisabledGroup(isPlayingOrWillChangePlaymode || isPrefab);
            DrawIsPreviewInEditor();
            if (gpuModeRequested)
            {
                EditorGUILayout.HelpBox("GPU Vertex Animation decoding is not available in editor preview mode. Standard CPU decoding will be used.", MessageType.Info);
            }
            else if (isPrefab)
            {
                EditorGUILayout.HelpBox("Preview in editor is disabled on prefab and prefab instances due to performance reasons. Use play mode or break the prefab connection through the GameObject menu.", MessageType.Info);
            }
            EditorGUI.EndDisabledGroup();

            bool isPlayingOrPreviewInEditor = isPlayingOrWillChangePlaymode || ac_.PreviewInEditor;

            EditorGUI.BeginDisabledGroup(!isPlayingOrPreviewInEditor);
            EditorGUI.BeginChangeCheck();

            editorFrame_ = Mathf.Clamp(ac_.LastReadFrame, 0, ac_.LastFrame);
            if (ac_.interpolate)
            {
                editorFrame_ = EditorGUILayout.Slider(new GUIContent("Frame"), editorFrame_, 0, ac_.LastFrame);
            }
            else
            {
                editorFrame_ = EditorGUILayout.IntSlider(new GUIContent("Frame"), (int)editorFrame_, 0, ac_.LastFrame);
            }
            if (EditorGUI.EndChangeCheck() && isPlayingOrPreviewInEditor)
            {
                ac_.SetFrame(editorFrame_);
                SceneView.RepaintAll();
            }

            EditorGUI.EndDisabledGroup();
            EditorGUILayout.LabelField(new GUIContent("Time"), new GUIContent(ac_.AnimationTime.ToString("F3")));
            EditorGUILayout.LabelField(new GUIContent("Frame Count"), new GUIContent(ac_.FrameCount.ToString()));
            EditorGUILayout.LabelField(new GUIContent("FPS"), new GUIContent(ac_.Fps.ToString()));
            EditorGUILayout.LabelField(new GUIContent("Animation Length"), new GUIContent(ac_.AnimationLength.ToString()));
            EditorGUILayout.LabelField(new GUIContent("Compression type"), new GUIContent(GetCompressionTypeString()));

            EditorGUILayout.Space();
            EditorGUI.BeginDisabledGroup(ac_.AnimatorSync != null);
            DrawStartTimeOffset();
            EditorGUI.EndDisabledGroup();
            DrawSyncWithAnimator();
            CRGUIUtils.Splitter();

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);

            CRGUIUtils.Splitter();

            EditorGUILayout.Space();

            EditorGUI.EndDisabledGroup();

            if (isPlayingOrWillChangePlaymode)
            {
                Repaint();
            }
        }