Beispiel #1
0
    private void CreatePreviewInstances()
    {
        this.DestroyPreviewInstances();
        if (this.m_previewInstance == null)
        {
            try {
                string skinName = EditorPrefs.GetString(m_skeletonDataAssetGUID + "_lastSkin", "");

                m_previewInstance           = SpineEditorUtilities.SpawnAnimatedSkeleton((SkeletonDataAsset)target, skinName).gameObject;
                m_previewInstance.hideFlags = HideFlags.HideAndDontSave;
                m_previewInstance.layer     = 0x1f;


                m_skeletonAnimation = m_previewInstance.GetComponent <SkeletonAnimation>();
                m_skeletonAnimation.initialSkinName = skinName;
                m_skeletonAnimation.LateUpdate();

                m_skeletonData = m_skeletonAnimation.skeletonDataAsset.GetSkeletonData(true);

                m_previewInstance.renderer.enabled = false;

                m_initialized = true;
                AdjustCameraGoals(true);
            } catch {
            }
        }
    }
Beispiel #2
0
    private void Initialize(SkeletonDataAsset skeletonDataAsset, string skinName = "")
    {
        if (_previewRenderUtility != null)
        {
            return;
        }
        _previewRenderUtility = new PreviewRenderUtility(true);
        _lastANimationTime    = currentTime;

        if (_previewGameObject == null)
        {
            _previewGameObject = SpineEditorUtilities.SpawnAnimatedSkeleton(skeletonDataAsset, skinName).gameObject;

            if (_previewGameObject != null)
            {
                _previewGameObject.hideFlags       = HideFlags.HideAndDontSave;
                _previewGameObject.layer           = PreviewLayer;
                _skeletonAnimation                 = _previewGameObject.GetComponent <SkeletonAnimation>();
                _skeletonAnimation.initialSkinName = skinName;
                _skeletonAnimation.LateUpdate();
                //初始化时不进行渲染
                _previewGameObject.GetComponent <Renderer>().enabled = false;
            }
            _requireRefresh = true;
        }
        InitializePreviewCamera();
    }
Beispiel #3
0
    private void CreatePreviewInstances()
    {
        this.DestroyPreviewInstances();
        if (this.m_previewInstance == null)
        {
            string            skinName = EditorPrefs.GetString(m_skeletonDataAssetGUID + "_lastSkin", "");
            SkeletonAnimation skelAnim = SpineEditorUtilities.SpawnAnimatedSkeleton((SkeletonDataAsset)target, skinName);
            if (skelAnim == null)
            {
                failedSkeletonDataLatch = true;
                //EditorUtility.DisplayDialog("Skeleton / SpriteCollection Mismatch",  "GetSkeletonData failed, make sure JSON and SpriteCollection match.\nSprite Collection must contain all attachments referenced in SkeletonJSON", "OK");
                return;                 //failed
            }

            m_previewInstance = skelAnim.gameObject;
            //m_previewInstance.transform.localScale = Vector3.one * 0.01f;
            m_previewInstance.hideFlags = HideFlags.HideAndDontSave;
            m_previewInstance.layer     = 0x1f;


            m_skeletonAnimation = m_previewInstance.GetComponent <SkeletonAnimation>();
            m_skeletonAnimation.initialSkinName = skinName;
            m_skeletonAnimation.LateUpdate();
            m_skeletonData = m_skeletonAnimation.skeletonDataAsset.GetSkeletonData(true);

            m_previewInstance.renderer.enabled = false;

            m_initialized = true;
            AdjustCameraGoals(true);
        }
    }