Пример #1
0
    /// <summary>
    /// 播放UI动画
    /// </summary>
    /// <param name="animationName">动画名称</param>
    /// <param name="lifeTime">动画时间</param>
    /// <param name="parentTfm">动画挂载点</param>
    /// <param name="assetBundle">动画资源包</param>
    /// <param name="audioID">音效ID</param>
    public static GameObject PlayUIAnim(string animationName, float lifeTime, Transform parentTfm, AssetBundle assetBundle, int audioID = 0)
    {
        if (string.IsNullOrEmpty(animationName))
        {
            return(null);
        }
        if (parentTfm == null)
        {
            Debug.Log("动画挂载点不存在!!!");
            return(null);
        }
        if (assetBundle == null)
        {
            Debug.Log("动画资源加载失败!!!");
            return(null);
        }
        UnityEngine.Object obj     = assetBundle.LoadAsset(animationName);
        GameObject         gameObj = (GameObject)GameMain.instantiate(obj);

        gameObj.transform.SetParent(parentTfm, false);
        DragonBones.UnityArmatureComponent animate = gameObj.GetComponentInChildren <DragonBones.UnityArmatureComponent>();
        animate.animation.Play("newAnimation");
        if (lifeTime > 0f)
        {
            GameObject.Destroy(gameObj, lifeTime);
        }

        if (audioID != 0)
        {
            CustomAudioDataManager.GetInstance().PlayAudio(audioID);
        }

        return(gameObj);
    }
    public void StrobeAlpha(DragonBones.UnityArmatureComponent p_sprite, int p_strobeCount, float a)
    {
        DragonBones.ColorTransform oldColor = p_sprite.color;
        Color toStrobe = new Color(0, 0, 0, a);

        StrobeColor(p_sprite, p_strobeCount, toStrobe);
    }
Пример #3
0
 private void Start()
 {
     _transform          = GetComponent <Transform>();
     _rigidbody          = GetComponent <Rigidbody2D>();
     _animatorController = GetComponent <Drag.UnityArmatureComponent>();
     _directionState     = transform.localScale.x > 0 ? DirectionState.Right : DirectionState.Left;
 }
    static int Dispose(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                DragonBones.UnityArmatureComponent obj = (DragonBones.UnityArmatureComponent)ToLua.CheckObject <DragonBones.UnityArmatureComponent>(L, 1);
                obj.Dispose();
                return(0);
            }
            else if (count == 2)
            {
                DragonBones.UnityArmatureComponent obj = (DragonBones.UnityArmatureComponent)ToLua.CheckObject <DragonBones.UnityArmatureComponent>(L, 1);
                bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
                obj.Dispose(arg0);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.UnityArmatureComponent.Dispose"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Пример #5
0
 void Start()
 {
     armature         = GetComponent <DragonBones.UnityArmatureComponent>();
     targetAnimations = idle;
     time             = Random.Range(minTimeAnimation, maxTimeAnimations);
     armature.animation.FadeIn(idle);
 }
    public Sprite[] image_Number;    //头像种类


    /*——————————————————————————————————————————————————————————————*/
    /*—————————————————————— START 函数 和 UPDATE 函数———————————————————————————*/
    /*——————————————————————————————————————————————————————————————*/

    void Start()
    {
        //初始化
        roleArmatureComponent = GetComponent <DragonBones.UnityArmatureComponent>();                                              //抓龙骨
        animaType             = 0;                                                                                                //一开始静止动画
        saveAnimaTypeChange   = 0;                                                                                                //当前状态是静止
        targetPosition        = new Vector3(this.transform.position.x + 3, this.transform.position.y, this.transform.position.z); //目标地址设在主角左边3长度的地方,实现一开始自动走进场景
    }
    public void RemotoPararAnim(string gbjn)
    {
        GameObject remotoGbj = GameObject.Find(gbjn);

        DragonBones.UnityArmatureComponent dbs =
            remotoGbj.GetComponent <DragonBones.UnityArmatureComponent>();
        dbs.animation.Stop();
    }
 public void Blink(MeshRenderer p_sprite, int p_strobeCount)
 {
     DragonBones.UnityArmatureComponent DBComponent = p_sprite.transform.GetComponent <DragonBones.UnityArmatureComponent>();
     if (DBComponent != null)
     {
         DBComponent.StartCoroutine(BlinkCoroutine(DBComponent, 0, ((p_strobeCount * 2) - 1), p_sprite, p_sprite.enabled));
     }
 }
Пример #9
0
    void Start()
    {
        rb   = GetComponent <Rigidbody2D>();
        col  = GetComponent <BoxCollider2D>();
        ac   = GetComponent <AudioSource>();
        anim = GetComponent <DragonBones.UnityArmatureComponent>();

        defaultScaleX = transform.localScale.x;
    }
    // --- Color change : broken

    public void StrobeColor(DragonBones.UnityArmatureComponent p_sprite, int p_strobeCount, Color p_colorToStrobe)
    {
        DragonBones.ColorTransform oldColor = p_sprite.color;
        DragonBones.ColorTransform newColor = new DragonBones.ColorTransform();
        newColor.redOffset   = (int)p_colorToStrobe.r * 255;
        newColor.greenOffset = (int)p_colorToStrobe.g * 255;
        newColor.blueOffset  = (int)p_colorToStrobe.b * 255;
        //newColor.alphaOffset = (int)p_colorToStrobe.a * 255;
        p_sprite.StartCoroutine(StrobeColorHelper(0, ((p_strobeCount * 2) - 1), p_sprite, oldColor, newColor));
    }
Пример #11
0
 /**
  * @language zh_CN
  * 刷新贴图集数据中贴图。
  * @see #ParseTextureAtlasData()
  * @see #GetTextureAtlasData()
  * @see #AddTextureAtlasData()
  * @see #RemoveTextureAtlasData()
  * @see DragonBones.UnityTextureAtlasData
  */
 public void RefreshAllTextureAtlas(UnityArmatureComponent unityArmature)
 {
     foreach (var textureAtlasDatas in _textureAtlasDataMap.Values)
     {
         foreach (UnityTextureAtlasData textureAtlasData in textureAtlasDatas)
         {
             _refreshTextureAtlas(textureAtlasData, unityArmature.isUGUI);
         }
     }
 }
Пример #12
0
 private void DestroyPreviewInstances()
 {
     if (_previewUnityArmatureComp != null)
     {
         _previewUnityArmatureComp.Dispose(false);
         DestroyImmediate(_previewUnityArmatureComp.gameObject);
         _previewUnityArmatureComp = null;
     }
     m_PreviewUtility = null;
 }
        void OnEnable()
        {
            _armatureComponent = target as UnityArmatureComponent;
            if (_IsPrefab())
            {
                return;
            }

            //
            _nowTime           = System.DateTime.Now.Ticks;
            _sortingLayerNames = _GetSortingLayerNames();
            _sortingLayerIndex = _sortingLayerNames.IndexOf(_armatureComponent.sortingLayerName);

            // Update armature.
            if (!EditorApplication.isPlayingOrWillChangePlaymode &&
                _armatureComponent.armature == null &&
                _armatureComponent.unityData != null &&
                !string.IsNullOrEmpty(_armatureComponent.armatureName))
            {
                //clear cache
                UnityFactory.factory.Clear(true);
                // Load data.
                var dragonBonesData = UnityFactory.factory.LoadData(_armatureComponent.unityData);

                // Refresh texture atlas.
                UnityFactory.factory.RefreshAllTextureAtlas(_armatureComponent);

                // Refresh armature.
                UnityEditor.ChangeArmatureData(_armatureComponent, _armatureComponent.armatureName, dragonBonesData.name);

                // Refresh texture.
                _armatureComponent.armature.InvalidUpdate(null, true);

                // Play animation.
                if (!string.IsNullOrEmpty(_armatureComponent.animationName))
                {
                    _armatureComponent.animation.Play(_armatureComponent.animationName, _armatureComponent.playTimes);
                }
                _armatureComponent.CollectBones();
            }

            // Update hideFlags.
            if (!EditorApplication.isPlayingOrWillChangePlaymode &&
                _armatureComponent.armature != null &&
                _armatureComponent.armature.parent != null)
            {
                _armatureComponent.gameObject.hideFlags = HideFlags.NotEditable;
            }
            else
            {
                _armatureComponent.gameObject.hideFlags = HideFlags.None;
            }

            _UpdateParameters();
        }
Пример #14
0
        public static void ReplaceAnimation(UnityArmatureComponent _armatureComponent, string armatureName)
        {
            _armatureComponent.armatureBaseName = armatureName;

            if (!string.IsNullOrEmpty(armatureName))
            {
                string       dragonBonesName  = _armatureComponent.unityData.dataName;
                ArmatureData baseDiceArmature = UnityFactory.factory.GetArmatureData(armatureName, dragonBonesName);
                UnityFactory.factory.ReplaceAnimation(_armatureComponent.armature, baseDiceArmature);
            }
        }
Пример #15
0
        private static bool _changeDragonBonesData(UnityArmatureComponent _armatureComponent, TextAsset dragonBoneJSON)
        {
            if (dragonBoneJSON != null)
            {
                var textureAtlasJSONs = new List <string>();
                _getTextureAtlasConfigs(textureAtlasJSONs, AssetDatabase.GetAssetPath(dragonBoneJSON.GetInstanceID()));

                var dragonBonesData = _armatureComponent.LoadData(dragonBoneJSON, textureAtlasJSONs);
                if (dragonBonesData != null)
                {
                    Undo.RecordObject(_armatureComponent, "Set DragonBones");

                    _armatureComponent.dragonBonesJSON  = dragonBoneJSON;
                    _armatureComponent.textureAtlasJSON = textureAtlasJSONs;

                    //_clearGameObjectChildren(_armatureComponent.gameObject);

                    var armatureName = dragonBonesData.armatureNames[0];
                    _changeArmatureData(_armatureComponent, armatureName, dragonBonesData.name);

                    _armatureComponent.gameObject.name = armatureName;

                    EditorUtility.SetDirty(_armatureComponent);

                    return(true);
                }
                else
                {
                    EditorUtility.DisplayDialog("Error", "Could not load dragonBones data.", "OK", null);

                    return(false);
                }
            }
            else if (_armatureComponent.dragonBonesJSON != null)
            {
                Undo.RecordObject(_armatureComponent, "Set DragonBones");

                _armatureComponent.dragonBonesJSON = null;

                if (_armatureComponent.armature != null)
                {
                    _armatureComponent.Dispose(false);
                }

                //_clearGameObjectChildren(_armatureComponent.gameObject);

                EditorUtility.SetDirty(_armatureComponent);

                return(true);
            }

            return(false);
        }
        //
        public static void OpenWindow(UnityArmatureComponent armatureComp)
        {
            if (armatureComp == null)
            {
                return;
            }

            //
            var win = GetWindow <PickJsonDataWindow>();

            win._armatureComp = armatureComp;
        }
Пример #17
0
        void OnEnable()
        {
            _armatureComponent = target as UnityArmatureComponent;
            _dragonBoneJSON    = _armatureComponent == null ? null : _armatureComponent.dragonBonesJSON; //

            //
            _nowTime           = System.DateTime.Now.Ticks;
            _sortingLayerNames = _getSortingLayerNames();
            _sortingLayerIndex = _sortingLayerNames.IndexOf(_armatureComponent.sortingLayerName);

            // Update armature.
            if (
                !EditorApplication.isPlayingOrWillChangePlaymode &&
                _armatureComponent.armature == null &&
                _armatureComponent.dragonBonesJSON != null &&
                !string.IsNullOrEmpty(_armatureComponent.armatureName)
                )
            {
                // Load data.
                var dragonBonesData = _armatureComponent.LoadData(_armatureComponent.dragonBonesJSON, _armatureComponent.textureAtlasJSON);

                // Refresh texture atlas.
                UnityFactory.factory.RefreshAllTextureAtlas();

                // Refresh armature.
                _changeArmatureData(_armatureComponent, _armatureComponent.armatureName, dragonBonesData.name);

                // Refresh texture.
                _armatureComponent.armature.InvalidUpdate(null, true);

                // Play animation.
                if (!string.IsNullOrEmpty(_armatureComponent.animationName))
                {
                    _armatureComponent.animation.Play(_armatureComponent.animationName);
                }
            }

            // Update hideFlags.
            if (!EditorApplication.isPlayingOrWillChangePlaymode &&
                _armatureComponent.armature != null &&
                _armatureComponent.armature.parent != null
                )
            {
                _armatureComponent.gameObject.hideFlags = HideFlags.NotEditable;
            }
            else
            {
                _armatureComponent.gameObject.hideFlags = HideFlags.None;
            }

            //
            _updateParameters();
        }
Пример #18
0
        public static bool ChangeDragonBonesData(UnityArmatureComponent _armatureComponent, TextAsset dragonBoneJSON)
        {
            if (dragonBoneJSON != null)
            {
                var textureAtlasJSONs = new List <string>();
                UnityEditor.GetTextureAtlasConfigs(textureAtlasJSONs, AssetDatabase.GetAssetPath(dragonBoneJSON.GetInstanceID()));

                UnityDragonBonesData.TextureAtlas[] textureAtlas = UnityEditor.GetTextureAtlasByJSONs(textureAtlasJSONs);

                UnityDragonBonesData data = UnityEditor.CreateUnityDragonBonesData(dragonBoneJSON, textureAtlas);
                _armatureComponent.unityData = data;

                var dragonBonesData = UnityFactory.factory.LoadData(data, _armatureComponent.isUGUI);
                if (dragonBonesData != null)
                {
                    Undo.RecordObject(_armatureComponent, "Set DragonBones");

                    _armatureComponent.unityData = data;

                    var armatureName = dragonBonesData.armatureNames[0];
                    ChangeArmatureData(_armatureComponent, armatureName, _armatureComponent.unityData.dataName);

                    _armatureComponent.gameObject.name = armatureName;

                    EditorUtility.SetDirty(_armatureComponent);

                    return(true);
                }
                else
                {
                    EditorUtility.DisplayDialog("Error", "Could not load dragonBones data.", "OK", null);

                    return(false);
                }
            }
            else if (_armatureComponent.unityData != null)
            {
                Undo.RecordObject(_armatureComponent, "Set DragonBones");

                _armatureComponent.unityData = null;

                if (_armatureComponent.armature != null)
                {
                    _armatureComponent.Dispose(false);
                }

                EditorUtility.SetDirty(_armatureComponent);

                return(true);
            }

            return(false);
        }
Пример #19
0
        public static void OpenWindow(UnityArmatureComponent armatureComp)
        {
            if (armatureComp == null)
            {
                return;
            }

            var win = GetWindowWithRect(typeof(ShowSlotsWindow), new Rect(0.0f, 0.0f, WIDTH, HEIGHT), false) as ShowSlotsWindow;

            win._armatureComp = armatureComp;
            win.titleContent  = new GUIContent("SlotList");
            win.Show();
        }
Пример #20
0
        /**
         * @private
         */
        override protected void _addDisplay()
        {
            _proxy = _armature.eventDispatcher as UnityArmatureComponent;
            var container = _proxy.slotsRoot;

            if (_renderDisplay.transform.parent != container.transform)
            {
                _renderDisplay.transform.SetParent(container.transform);

                _helpVector3.Set(0.0f, 0.0f, -_zOrder * (_proxy.zSpace + 0.001f));
                _renderDisplay.transform.localPosition = _helpVector3;
            }
        }
Пример #21
0
        /**
         * @private
         */
        protected override void _AddDisplay()
        {
            _proxy = _armature.proxy as UnityArmatureComponent;
            var container = _proxy;

            if (_renderDisplay.transform.parent != container.transform)
            {
                _renderDisplay.transform.SetParent(container.transform);

                _helpVector3.Set(0.0f, 0.0f, -_zOrder * (_proxy.zSpace + 0.001f));
                _SetZorder(_helpVector3);
            }
        }
    public void RemotoFliparY(string obj_int)
    {
        string[]   ids       = obj_int.Split('.');
        GameObject remotoGbj = GameObject.Find(ids[0]);

        if (remotoGbj == null)
        {
            Debug.LogWarning("GameObject \"" + ids[0] + "\" não encontrado");
        }

        DragonBones.UnityArmatureComponent dbs =
            remotoGbj.GetComponent <DragonBones.UnityArmatureComponent>();
        dbs.armature.flipY = int.Parse(ids[1]) != 0;
    }
    public void RemotoTocarAnim(string obj_anim_qtd)
    {
        string[]   ids       = obj_anim_qtd.Split('.');
        GameObject remotoGbj = GameObject.Find(ids[0]);

        if (remotoGbj == null)
        {
            Debug.LogWarning("GameObject \"" + ids[0] + "\" não encontrado");
        }

        DragonBones.UnityArmatureComponent dbs =
            remotoGbj.GetComponent <DragonBones.UnityArmatureComponent>();
        dbs.animation.Play(ids[1], int.Parse(ids[2]));
    }
 static int ShowBones(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         DragonBones.UnityArmatureComponent obj = (DragonBones.UnityArmatureComponent)ToLua.CheckObject(L, 1, typeof(DragonBones.UnityArmatureComponent));
         obj.ShowBones();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int DBUpdate(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         DragonBones.UnityArmatureComponent obj = (DragonBones.UnityArmatureComponent)ToLua.CheckObject <DragonBones.UnityArmatureComponent>(L, 1);
         obj.DBUpdate();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #26
0
    // Use this for initialization
    void Start()
    {
        //获取声音
        m_FireSound = GetComponent <AudioSource>();
        m_FireSound.Stop();

        m_AnimCtrl = transform.Find("Anime_01").GetComponent <DragonBones.UnityArmatureComponent>();
        m_AnimCtrl.AddEventListener(DragonBones.EventObject.COMPLETE, AnimationEventHandler);

        m_LineImg = transform.Find(m_Data.m_szBulletPoint[0]).GetComponentInChildren <Image>();

        PlayAnim("up");

        CustomAudioDataManager.GetInstance().PlayAudio(1005);
    }
Пример #27
0
 static int RefreshAllTextureAtlas(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.UnityFactory           obj  = (DragonBones.UnityFactory)ToLua.CheckObject <DragonBones.UnityFactory>(L, 1);
         DragonBones.UnityArmatureComponent arg0 = (DragonBones.UnityArmatureComponent)ToLua.CheckObject <DragonBones.UnityArmatureComponent>(L, 2);
         obj.RefreshAllTextureAtlas(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    private IEnumerator BlinkCoroutine(DragonBones.UnityArmatureComponent DBComponent, int p_i, int p_stopAt, MeshRenderer p_mySprite, bool p_startEnable)
    {
        if (p_i <= p_stopAt)
        {
            p_mySprite.enabled = !p_mySprite.enabled;

            yield return(new WaitForSeconds(m_blinkingInterval));

            DBComponent.StartCoroutine(BlinkCoroutine(DBComponent, (p_i + 1), p_stopAt, p_mySprite, p_startEnable));
        }
        else
        {
            p_mySprite.enabled = p_startEnable;
        }
    }
Пример #29
0
 void Start()
 {
     _unityArmature = GetComponent <UnityArmatureComponent>();
     if (_unityArmature.isUGUI)
     {
         Destroy(gameObject);
         return;
     }
     _mesh = new Mesh();
     _mesh.MarkDynamic();
     if (_unityArmature.armature != null)
     {
         UpdateMesh();
     }
 }
 static int Dispose(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.UnityArmatureComponent obj = (DragonBones.UnityArmatureComponent)ToLua.CheckObject(L, 1, typeof(DragonBones.UnityArmatureComponent));
         bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
         obj.Dispose(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }