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));
        }
    }
예제 #2
0
        public static void ChangeArmatureData(UnityArmatureComponent _armatureComponent, string armatureName, string dragonBonesName)
        {
            bool isUGUI = _armatureComponent.isUGUI;
            UnityDragonBonesData unityData = null;
            Slot slot = null;

            if (_armatureComponent.armature != null)
            {
                unityData = _armatureComponent.unityData;
                slot      = _armatureComponent.armature.parent;
                _armatureComponent.Dispose(false);

                UnityFactory.factory._dragonBones.AdvanceTime(0.0f);

                _armatureComponent.unityData = unityData;
            }

            _armatureComponent.armatureName = armatureName;
            _armatureComponent.isUGUI       = isUGUI;

            _armatureComponent = UnityFactory.factory.BuildArmatureComponent(_armatureComponent.armatureName, dragonBonesName, null, _armatureComponent.unityData.dataName, _armatureComponent.gameObject, _armatureComponent.isUGUI);
            if (slot != null)
            {
                slot.childArmature = _armatureComponent.armature;
            }

            _armatureComponent.sortingLayerName = _armatureComponent.sortingLayerName;
            _armatureComponent.sortingOrder     = _armatureComponent.sortingOrder;
        }
예제 #3
0
 private void DestroyPreviewInstances()
 {
     if (_previewUnityArmatureComp != null)
     {
         _previewUnityArmatureComp.Dispose(false);
         DestroyImmediate(_previewUnityArmatureComp.gameObject);
         _previewUnityArmatureComp = null;
     }
     m_PreviewUtility = null;
 }
예제 #4
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);
        }
예제 #5
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);
        }
 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));
     }
 }
예제 #7
0
        private void _changeArmature(string armatureName, string dragonBonesName)
        {
            Slot slot = null;

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

            _armatureComponent.armatureName = armatureName;
            _armatureComponent = UnityFactory.factory.BuildArmatureComponent(_armatureComponent.armatureName, dragonBonesName, null, _armatureComponent.gameObject);

            if (slot != null)
            {
                slot.childArmature = _armatureComponent.armature;
                UnityFactory.clock.Remove(_armatureComponent.armature);
            }
        }
예제 #8
0
        public static void ChangeArmatureData(UnityArmatureComponent _armatureComponent, string armatureName, string dragonBonesName)
        {
            Slot slot = null;

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

            _armatureComponent = UnityFactory.factory.BuildArmatureComponent(_armatureComponent.armatureName, dragonBonesName, null, _armatureComponent.unityData.dataName, _armatureComponent.gameObject, _armatureComponent.isUGUI);
            if (slot != null)
            {
                slot.childArmature = _armatureComponent.armature;
            }

            _armatureComponent.sortingLayerName = _armatureComponent.sortingLayerName;
            _armatureComponent.sortingOrder     = _armatureComponent.sortingOrder;
        }
예제 #9
0
        public override void OnInspectorGUI()
        {
            // DragonBones Data
            GUILayout.BeginHorizontal();

            _dragonBoneJSON = EditorGUILayout.ObjectField("DragonBones Data", _dragonBoneJSON, typeof(TextAsset), false) as TextAsset;

            if (
                _armatureComponent.dragonBonesJSON != _dragonBoneJSON &&
                GUILayout.Button(_armatureComponent.armature == null ? "Create" : "Change")
                )
            {
                if (_dragonBoneJSON != null)
                {
                    var textureAtlasJSON = new List <string>();
                    _getTextureAtlasConfigs(textureAtlasJSON, AssetDatabase.GetAssetPath(_dragonBoneJSON.GetInstanceID()));

                    var dragonBonesData = _armatureComponent.LoadData(_dragonBoneJSON, textureAtlasJSON);
                    if (dragonBonesData != null)
                    {
                        _armatureComponent.dragonBonesJSON  = _dragonBoneJSON;
                        _armatureComponent.textureAtlasJSON = textureAtlasJSON;

                        _clearGameObjectChildren(_armatureComponent.gameObject);
                        _changeArmature(dragonBonesData.armatureNames[0], dragonBonesData.name);
                        _update();
                    }
                    else
                    {
                        _dragonBoneJSON = _armatureComponent.dragonBonesJSON;

                        EditorUtility.DisplayDialog("Error", "Could not load dragonBones data.", "OK", null);
                    }
                }
                else
                {
                    _armatureComponent.dragonBonesJSON = null;

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

                    _clearGameObjectChildren(_armatureComponent.gameObject);
                }
            }

            GUILayout.EndHorizontal();

            EditorGUILayout.Space();

            if (_armatureComponent.armature != null)
            {
                var dragonBonesData = _armatureComponent.armature.armatureData.parent;

                // Armature
                if (UnityFactory.factory.GetAllDragonBonesData().ContainsValue(dragonBonesData) && _armatureNames != null)
                {
                    var armatureIndex = EditorGUILayout.Popup("Armature", _armatureIndex, _armatureNames.ToArray());
                    if (_armatureIndex != armatureIndex)
                    {
                        _armatureIndex = armatureIndex;
                        _clearGameObjectChildren(_armatureComponent.gameObject);
                        _changeArmature(_armatureNames[_armatureIndex], dragonBonesData.name);

                        _update();

                        EditorUtility.SetDirty(_armatureComponent);
                    }
                }

                // Animation
                if (_animationNames != null && _animationNames.Count > 0)
                {
                    GUILayout.BeginHorizontal();
                    var animationIndex = EditorGUILayout.Popup("Animation", _animationIndex, _animationNames.ToArray());
                    if (animationIndex != _animationIndex)
                    {
                        _animationIndex = animationIndex;
                        _armatureComponent.animationName = _animationNames[animationIndex];
                        _armatureComponent.animation.Play(_armatureComponent.animationName);

                        _update();

                        EditorUtility.SetDirty(_armatureComponent);
                    }

                    if (_animationIndex >= 0)
                    {
                        if (_armatureComponent.animation.isPlaying)
                        {
                            if (GUILayout.Button("Stop"))
                            {
                                _armatureComponent.animation.Stop();
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("Play"))
                            {
                                _armatureComponent.animation.Play();
                            }
                        }
                    }

                    GUILayout.EndHorizontal();
                }

                EditorGUILayout.Space();

                // Sorting Layer
                _sortingLayerIndex = EditorGUILayout.Popup("Sorting Layer", _sortingLayerIndex, _sortingLayerNames);
                if (_sortingLayerNames[_sortingLayerIndex] != _armatureComponent.sortingLayerName)
                {
                    Undo.RecordObject(_armatureComponent, "Sorting Layer");
                    _armatureComponent.sortingLayerName = _sortingLayerNames[_sortingLayerIndex];
                    EditorUtility.SetDirty(_armatureComponent);
                }

                // Sorting Order
                var sortingOrder = EditorGUILayout.IntField("Order in Layer", _armatureComponent.sortingOrder);
                if (sortingOrder != _armatureComponent.sortingOrder)
                {
                    Undo.RecordObject(_armatureComponent, "Edit Sorting Order");
                    _armatureComponent.sortingOrder = sortingOrder;
                    EditorUtility.SetDirty(_armatureComponent);
                }

                // ZSpace
                GUILayout.BeginHorizontal();
                _armatureComponent.zSpace = EditorGUILayout.Slider("Z Space", _armatureComponent.zSpace, 0.0f, 0.2f);
                GUILayout.EndHorizontal();

                // TimeScale
                GUILayout.BeginHorizontal();
                _armatureComponent.animation.timeScale = EditorGUILayout.Slider("Time Scale", _armatureComponent.animation.timeScale, 0.0f, 2.0f);
                GUILayout.EndHorizontal();

                EditorGUILayout.Space();
            }

            if (!EditorApplication.isPlayingOrWillChangePlaymode && Selection.activeObject == _armatureComponent.gameObject)
            {
                EditorUtility.SetDirty(_armatureComponent);
                HandleUtility.Repaint();
            }
        }
예제 #10
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 = new UnityDragonBonesData.TextureAtlas[textureAtlasJSONs.Count];
                 *              for(int i = 0;i < textureAtlasJSONs.Count; ++i)
                 * {
                 *                      string path = textureAtlasJSONs[i];
                 *                      //load textureAtlas data
                 *                      UnityDragonBonesData.TextureAtlas ta = new UnityDragonBonesData.TextureAtlas();
                 *                      ta.textureAtlasJSON = AssetDatabase.LoadAssetAtPath<TextAsset>(path);
                 *                      //load texture
                 *                      path = path.Substring(0,path.LastIndexOf(".json"));
                 *                      ta.texture = AssetDatabase.LoadAssetAtPath<Texture2D>(path+".png");
                 *                      //load material
                 *                      ta.material = AssetDatabase.LoadAssetAtPath<Material>(path+"_Mat.mat");
                 *                      ta.uiMaterial = AssetDatabase.LoadAssetAtPath<Material>(path+"_UI_Mat.mat");
                 *                      textureAtlas[i] = ta;
                 *              }*/

                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, 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.unityData != null)
            {
                Undo.RecordObject(_armatureComponent, "Set DragonBones");

                _armatureComponent.unityData = null;

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

                EditorUtility.SetDirty(_armatureComponent);

                return(true);
            }

            return(false);
        }
예제 #11
0
        public static bool _changeDragonBonesData(UnityArmatureComponent _armatureComponent, TextAsset dragonBoneJSON, TextAsset textureAtlasJSON = null)
        {
            if (dragonBoneJSON != null)
            {
                //龙骨图集的url
                string texturePath     = AssetDatabase.GetAssetPath(dragonBoneJSON.GetInstanceID());
                string textureAtlasUrl = texturePath;
                string textureName     = "";
                string suffix          = "";
                if (textureAtlasJSON != null)
                {
                    texturePath = textureAtlasUrl = AssetDatabase.GetAssetPath(textureAtlasJSON.GetInstanceID());
                    textureName = textureAtlasJSON.name;
                    int index = textureAtlasUrl.LastIndexOf("Assets/") + 1;
                    textureAtlasUrl = textureAtlasUrl.Substring(index + 7);
                    //textureAtlasUrl = textureAtlasUrl.Remove(index);
                    //index = textureAtlasUrl.IndexOf("Resources/") + "Resources/".Length;
                    //textureAtlasUrl = textureAtlasUrl.Substring(index, textureAtlasUrl.Length - index);
                }
                else
                {
                    suffix = "tex";
                    //textureAtlasUrl = AssetDatabase.GetAssetPath(textureAtlasJSON.GetInstanceID());
                    //index = textureAtlasUrl.IndexOf("Resources/");
                    //lastIndex = atlasUrl.LastIndexOf(".json");
                    //atlasUrl = atlasUrl.Substring(index + resLen, atlasUrl.Length - (index + resLen + ".json".Length));
                }

                var textureAtlasJSONs = new List <string>();
                _getTextureAtlasConfigs(textureAtlasJSONs, texturePath, null, suffix);

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

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

                    _clearGameObjectChildren(_armatureComponent.gameObject);
                    UnityFactory.factory.LoadTextureAtlasData(textureAtlasUrl + textureName, textureName);

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

                    _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);
                }

                EditorUtility.SetDirty(_armatureComponent);

                return(true);
            }

            return(false);
        }