示例#1
0
 public void Save()
 {
     if (!BTSerializer.Serialize(_behaviorTree, AssetDatabase.GetAssetPath(_selectedAsset.GetInstanceID())))
     {
         EditorUtility.DisplayDialog("ERROR", "Saving behavior tree failed, please look at console window", "OK");
     }
     AssetDatabase.Refresh();
 }
示例#2
0
    /// <summary>
    /// Show table in table view.
    /// </summary>
    /// <param name="idx"></param>
    void ShowTableData(int idx)
    {
        if (mFormManager == null)
        {
            return;
        }

        if (mFormManager.mTableList.Count > 0)
        {
            if (idx < mFormManager.mTableList.Count)
            {
                if (idx < 0)
                {
                    idx = GetFirst();
                }
                mCurrentColumnPage = 1;
                mCurrentRowPage    = 1;

                mSelectionIndex = idx;
                mSelectionAsset = mFormManager.mTableList[idx];

                mSelectionAssetPath = AssetDatabase.GetAssetPath(mSelectionAsset.GetInstanceID());
                mSelectionTable     = OOFormArray.ReadFromFile(mSelectionAssetPath);
            }
        }
    }
        public UnityTextureAtlasData LoadTextureAtlasData(TextAsset textureAtlasJSON, string name = null, float scale = 0.0f)
        {
            if (textureAtlasJSON == null)
            {
                return(null);
            }

            var textureAtlasData = this.ParseTextureAtlasData((Dictionary <string, object>)MiniJSON.Json.Deserialize(textureAtlasJSON.text), null, name, scale) as UnityTextureAtlasData;
            var path             = AssetDatabase.GetAssetPath(textureAtlasJSON.GetInstanceID());

            var index = path.LastIndexOf("Resources");

            if (index > 0)
            {
                path = path.Substring(index + 10);
            }

            index = path.LastIndexOf("/");
            if (index > 0)
            {
                textureAtlasData.imagePath = path.Substring(0, index + 1) + textureAtlasData.imagePath;
            }

            index = textureAtlasData.imagePath.LastIndexOf(".");
            if (index > 0)
            {
                textureAtlasData.imagePath = textureAtlasData.imagePath.Substring(0, index);
            }

            var textureAtlas = Resources.Load <Texture2D>(textureAtlasData.imagePath);

            textureAtlasData.texture = textureAtlas;

            return(textureAtlasData);
        }
    public override Hashtable EditorDragDrop(object o)
    {
        if (typeof(TextAsset).IsAssignableFrom(o.GetType()))
        {
            TextAsset ac = (TextAsset)o;

            string path = UnityEditor.AssetDatabase.GetAssetPath(ac.GetInstanceID( ));

            int index = path.IndexOf("Resources/");

            if (index > 0)
            {
                path = path.Substring(index + "Resources/".Length);

                int dot = path.LastIndexOf('.');
                if (dot >= 0)
                {
                    path = path.Substring(0, dot);
                }

                Hashtable hashtable = new Hashtable( );
                hashtable["name"] = path;

                return(hashtable);
            }
        }

        return(null);
    }
示例#5
0
    static void Save()
    {
        EditorPrefs.SetString("NGUI Partial", mPartial);
        EditorPrefs.SetString("NGUI Font Name", mFontName);
        EditorPrefs.SetString("NGUI Atlas Name", mAtlasName);
        EditorPrefs.SetString("NGUI Selected Sprite", mSpriteName);
        EditorPrefs.SetInt("NGUI Font Asset", (mFontData != null) ? mFontData.GetInstanceID() : -1);
        EditorPrefs.SetInt("NGUI Font Texture", (mFontTexture != null) ? mFontTexture.GetInstanceID() : -1);
        EditorPrefs.SetInt("NGUI Font", (mBitFont != null) ? mBitFont.GetInstanceID() : -1);
        EditorPrefs.SetInt("NGUI Atlas", (mAtlas != null) ? mAtlas.GetInstanceID() : -1);
        EditorPrefs.SetInt("NGUI Atlas Padding", mAtlasPadding);
        EditorPrefs.SetBool("NGUI Atlas Trimming", mAtlasTrimming);
        EditorPrefs.SetBool("NGUI Atlas PMA", mAtlasPMA);
        EditorPrefs.SetBool("NGUI Unity Packing", mUnityPacking);
        EditorPrefs.SetBool("NGUI Force Square Atlas", mForceSquare);
        EditorPrefs.SetInt("NGUI Pivot", (int)mPivot);
        EditorPrefs.SetInt("NGUI Layer", mLayer);
        EditorPrefs.SetInt("NGUI DynFont", (mDynFont != null) ? mDynFont.GetInstanceID() : -1);
        EditorPrefs.SetInt("NGUI DynFontStyle", (int)mDynFontStyle);
        EditorPrefs.SetInt("NGUI Color Mode", (int)mColorMode);
        EditorPrefs.SetBool("NGUI All DCs", mAllDCs);
        EditorPrefs.SetInt("NGUI Font Size", mFontSize);

        SaveColor();
    }
    public void OpenWithExcel(TextAsset asset)
    {
        string path     = AssetDatabase.GetAssetPath(asset.GetInstanceID());
        string all_path = Application.dataPath.Substring(0, Application.dataPath.Length - 6) + path;

        all_path = all_path.Replace("/", @"\");

        System.Diagnostics.Process.Start(OOFormOption.mOtherEditorPath, all_path);
    }
示例#7
0
        public void Load(TextAsset asset)
        {
            if (mAssetId != asset.GetInstanceID())
            {
                mAssetId = asset.GetInstanceID();

                if (!IsComplete)
                {
                    OnStop();
                }
                mFile.Load(asset);
                if (!mFile.Eof)
                {
                    OnStart();
                    Push(mFile);
                }
            }
        }
示例#8
0
 static void Save()
 {
     PlayerPrefs.SetString("NGUI Font Name", mFontName);
     PlayerPrefs.SetString("NGUI Atlas Name", mAtlasName);
     PlayerPrefs.SetInt("NGUI Font Asset", (mFontData != null) ? mFontData.GetInstanceID() : -1);
     PlayerPrefs.SetInt("NGUI Font Texture", (mFontTexture != null) ? mFontTexture.GetInstanceID() : -1);
     PlayerPrefs.SetInt("NGUI Font", (mFont != null) ? mFont.GetInstanceID() : -1);
     PlayerPrefs.SetInt("NGUI Atlas", (mAtlas != null) ? mAtlas.GetInstanceID() : -1);
     PlayerPrefs.SetInt("NGUI Preview", mPreview ? 0 : 1);
 }
    public static void Create()
    {
        TextAsset Asset = new TextAsset();

        UnityEditor.ProjectWindowUtil.StartNameEditingIfProjectWindowExists(
            Asset.GetInstanceID(),
            ScriptableObject.CreateInstance <LuaGameModeTemplateGenerator>(),
            "Assets.asset",
            AssetPreview.GetMiniThumbnail(Asset),
            null);
    }
示例#10
0
 private static void Save()
 {
     EditorPrefs.SetString("NGUI Font Name", mFontName);
     EditorPrefs.SetString("NGUI Atlas Name", mAtlasName);
     EditorPrefs.SetInt("NGUI Font Asset", (mFontData != null) ? mFontData.GetInstanceID() : -1);
     EditorPrefs.SetInt("NGUI Font Texture", (mFontTexture != null) ? mFontTexture.GetInstanceID() : -1);
     EditorPrefs.SetInt("NGUI Font", (mFont != null) ? mFont.GetInstanceID() : -1);
     EditorPrefs.SetInt("NGUI Atlas", (mAtlas != null) ? mAtlas.GetInstanceID() : -1);
     EditorPrefs.SetInt("NGUI Preview", mPreview ? 0 : 1);
     EditorPrefs.SetInt("NGUI Atlas Padding", mAtlasPadding);
     EditorPrefs.SetBool("NGUI Atlas Trimming", mAtlasTrimming);
 }
示例#11
0
        public void ExportTextAsset(TextAsset asset)
        {
            string assetPath  = AssetDatabase.GetAssetPath(asset.GetInstanceID()).Replace("Assets/", "");
            string exportPath = Path.Combine(assets.XmlDir, assetPath);

            if (!Directory.Exists(Path.GetDirectoryName(exportPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(exportPath));
            }
            File.WriteAllBytes(exportPath, asset.bytes);
            //Debug.Log("Exported Text asset to " + exportPath);
        }
示例#12
0
 protected void RefreshSource()
 {
     if (m_StringSource)
     {
         m_SourcePath    = AssetDatabase.GetAssetPath(m_StringSource.GetInstanceID());
         m_SourceContent = m_StringSource.text;
     }
     else
     {
         m_SourcePath    = "";
         m_SourceContent = "";
     }
 }
 public override string GetExportPath()
 {
     if (isMonoBehaviour)
     {
         TextAsset scriptAsset = Resources.Load <TextAsset>("src/" + this.logicClassName + ".js");
         unityAssetPath = AssetDatabase.GetAssetPath(scriptAsset.GetInstanceID());
         return(unityAssetPath.Replace(".js.txt", ".binding.ts"));
     }
     else
     {
         return("Assets/puerts/serializable/" + this.serializableTypeName + ".binding.ts");
     }
 }
示例#14
0
 void SetAsset(TextAsset textAsset)
 {
     mSelectionAsset = textAsset;
     if (textAsset == null)
     {
         mSelectionTable     = null;
         mSelectionAssetPath = "";
     }
     else
     {
         mSelectionTable     = OOFormArray.GetForm(textAsset.text);
         mSelectionAssetPath = AssetDatabase.GetAssetPath(textAsset.GetInstanceID());
     }
 }
示例#15
0
 static void Save()
 {
     PlayerPrefs.SetString("NGUI Font Name", mFontName);
     PlayerPrefs.SetString("NGUI Atlas Name", mAtlasName);
     PlayerPrefs.SetInt("NGUI Font Asset", (mFontData != null) ? mFontData.GetInstanceID() : -1);
     PlayerPrefs.SetInt("NGUI Font Texture", (mFontTexture != null) ? mFontTexture.GetInstanceID() : -1);
     PlayerPrefs.SetInt("NGUI Atlas", (mAtlas != null) ? mAtlas.GetInstanceID() : -1);
     PlayerPrefs.SetInt("NGUI Preview", mPreview ? 0 : 1);
     EditorPrefs.SetBool("NGUI Unity Packing", mUnityPacking);
     EditorPrefs.SetInt("NGUI Atlas Padding", mAtlasPadding);
     EditorPrefs.SetBool("NGUI Atlas Trimming", mAtlasTrimming);
     EditorPrefs.SetString("NGUI Partial", mPartial);
     EditorPrefs.SetInt("NGUI Pivot", (int)mPivot);
 }
示例#16
0
        public static Texture2D RefSharedWebpTexture(TextAsset webpAsset)
        {
            if (webpAsset == null)
            {
                return(null);
            }

            Texture2D sharedTexture    = null;
            string    sharedTextureKey = webpAsset.GetInstanceID().ToString();
            SharedWebpTextureEntry sharedWebpTextureEntry = GetSharedWebpTextureEntry(sharedTextureKey);

            if (sharedWebpTextureEntry != null)
            {
                // The texture might be already GCed
                if (sharedWebpTextureEntry.texture == null)
                {
                    sharedWebpTextures.Remove(sharedWebpTextureEntry);
                    sharedWebpTextureEntry = null;
                }
            }

            if (sharedWebpTextureEntry != null)
            {
                sharedWebpTextureEntry.refCount++;
                sharedTexture = sharedWebpTextureEntry.texture;
            }
            else
            {
                Status lError;
                sharedTexture = Texture2DExt.CreateTexture2DFromWebP(webpAsset.bytes, false, true, out lError, Texture2DExt.ScaleBy(1f));

                if (lError != Status.SUCCESS)
                {
//                    Debug.LogError ("SharedWebpTexture::RefSharedAlphaMaterial Webp Load Error : " + lError.ToString ());
                    return(null);
                }

                sharedWebpTextureEntry = new SharedWebpTextureEntry()
                {
                    assetId  = sharedTextureKey,
                    texture  = sharedTexture,
                    refCount = 1
                };

                sharedWebpTextures.Add(sharedWebpTextureEntry);
            }

            return(sharedTexture);
        }
        private CRAnimationAsset ConvertTextAssetToCRAnimationAsset(TextAsset textAsset, out string oldAssetPath)
        {
            oldAssetPath = AssetDatabase.GetAssetPath(textAsset.GetInstanceID());
            int    index           = oldAssetPath.IndexOf(textAsset.name + ".bytes");
            string assetDirectiory = oldAssetPath.Substring(0, index);

            string crAnimationFilePath = AssetDatabase.GenerateUniqueAssetPath(assetDirectiory + textAsset.name + ".asset");

            CRAnimationAsset crAnimationAsset = CRAnimationAsset.CreateInstance <CRAnimationAsset>();

            crAnimationAsset.Bytes = textAsset.bytes;
            AssetDatabase.CreateAsset(crAnimationAsset, crAnimationFilePath);

            return(crAnimationAsset);
        }
    void Save()
    {
        if (m_controllerDefData != null)
        {
            string jsonText = LitJson.JsonMapper.ToJson(m_controllerData);
            string path     = AssetDatabase.GetAssetPath(m_controllerDefData.GetInstanceID());

            File.WriteAllText(path, jsonText);
            AssetDatabase.Refresh();

            Debug.Log("Saved to: " + path);
        }
        else
        {
            Debug.LogWarning("Failed to save: No asset referenced. ");
        }
    }
示例#19
0
 static void Save()
 {
     EditorPrefs.SetString("NGUI Partial", mPartial);
     EditorPrefs.SetString("NGUI Font Name", mFontName);
     EditorPrefs.SetString("NGUI Atlas Name", mAtlasName);
     EditorPrefs.SetInt("NGUI Font Asset", (mFontData != null) ? mFontData.GetInstanceID() : -1);
     EditorPrefs.SetInt("NGUI Font Texture", (mFontTexture != null) ? mFontTexture.GetInstanceID() : -1);
     EditorPrefs.SetInt("NGUI Font", (mFont != null) ? mFont.GetInstanceID() : -1);
     EditorPrefs.SetInt("NGUI Atlas", (mAtlas != null) ? mAtlas.GetInstanceID() : -1);
     EditorPrefs.SetInt("NGUI Atlas Padding", mAtlasPadding);
     EditorPrefs.SetBool("NGUI Atlas Trimming", mAtlasTrimming);
     EditorPrefs.SetBool("NGUI Unity Packing", mUnityPacking);
     EditorPrefs.SetBool("NGUI Force Square Atlas", mForceSquare);
     EditorPrefs.SetInt("NGUI Pivot", (int)mPivot);
     EditorPrefs.SetInt("NGUI Layer", mLayer);
     SaveColor();
 }
示例#20
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);
        }
        private void SetUnityDragonBonesData()
        {
            List <string> textureAtlasJSONs = new List <string>();

            UnityEditor.GetTextureAtlasConfigs(textureAtlasJSONs, AssetDatabase.GetAssetPath(_dragonBoneJSONData.GetInstanceID()));
            UnityDragonBonesData.TextureAtlas[] textureAtlas = UnityEditor.GetTextureAtlasByJSONs(textureAtlasJSONs);

            UnityDragonBonesData data = UnityEditor.CreateUnityDragonBonesData(_dragonBoneJSONData, textureAtlas);

            _armatureComp.unityData = data;
        }
示例#22
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);
        }
示例#23
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();
            }
        }
        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);
        }
示例#25
0
    /// <summary>
    /// Set GIF texture from url
    /// </summary>
    /// <param name="url">GIF image url (WEB or StreamingAssets path)</param>
    /// <param name="autoPlay">Auto play after decode</param>
    /// <returns>IEnumerator</returns>
    public IEnumerator SetGifFromUrlCoroutine(string url, bool autoPlay = true)
    {
        if (gifTextAsset != null)
        {
            if (gifTexList.Count != 0 && rawImage != null)
            {
                rawImage.texture = gifTexList[0].texture2d;
            }

            yield return(StartCoroutine(UniGif.GetTextureListCoroutine(this, gifTextAsset.bytes, gifTextAsset.GetInstanceID(), gifTexList, (gtList, loop, w, h) =>
            {
                gifTexList = gtList;
                FinishedGetTextureList(loop, w, h, autoPlay);
            }, filterMode, wrapMode, outputDebugLog)));

            yield break;
        }

        if (string.IsNullOrEmpty(url))
        {
            Debug.LogError("URL is nothing.");
            yield break;
        }

        loading = true;

        string path;

        if (url.StartsWith("http"))
        {
            // from WEB
            path = url;
        }
        else
        {
            // from StreamingAssets
            path = System.IO.Path.Combine("file:///" + Application.streamingAssetsPath, url);
        }

        // Load file
        using (WWW www = new WWW(path)) {
            yield return(www);

            if (string.IsNullOrEmpty(www.error) == false)
            {
                Debug.LogError("File load error.\n" + www.error);
            }
            else
            {
                gifTexList.Clear();

                // Get GIF textures
                if (useCoroutineGetTexture)
                {
                    // use coroutine (avoid lock up but more slow)
                    yield return(StartCoroutine(UniGif.GetTextureListCoroutine(this, www.bytes, (gtList, loop, w, h) => {
                        gifTexList = gtList;
                        FinishedGetTextureList(loop, w, h, autoPlay);
                    }, filterMode, wrapMode, outputDebugLog)));
                }
                else
                {
                    // dont use coroutine (there is a possibility of lock up)
                    int loop, w, h;
                    gifTexList = UniGif.GetTextureList(www.bytes, out loop, out w, out h, filterMode, wrapMode, outputDebugLog);
                    FinishedGetTextureList(loop, w, h, autoPlay);
                }
            }
        }
    }
示例#26
0
        public override void OnInspectorGUI()
        {
            EditorGUI.BeginDisabledGroup(true);
            {
                EditorGUILayout.ObjectField("Script:", monoScript, typeof(MonoScript), false);
            }
            EditorGUI.EndDisabledGroup();

            TextAsset luaScriptText = null;

            if (!string.IsNullOrEmpty(scriptAssetPath))
            {
                luaScriptText = (TextAsset)AssetDatabase.LoadAssetAtPath(scriptAssetPath, typeof(TextAsset));
                if (luaScriptText == null)
                {
                    scriptAssetPath = "";
                }
            }
            TextAsset ta = (TextAsset)EditorGUILayout.ObjectField("Lua Script:", luaScriptText, typeof(TextAsset), false);

            if (ta == null)
            {
                if (!string.IsNullOrEmpty(behaviour.scriptShortPath))
                {
                    behaviour.scriptShortPath = "";
                    behaviour.scriptName      = "";
                }
                scriptAssetPath = "";
            }
            else
            {
                string taPath = AssetDatabase.GetAssetPath(ta.GetInstanceID()).Replace("\\", "/");
                if (taPath != scriptAssetPath && taPath.IndexOf(LuaScriptPathDir) >= 0)
                {
                    scriptAssetPath = taPath;

                    behaviour.scriptShortPath = scriptAssetPath.Replace(LuaScriptPathDir, "");
                    behaviour.scriptName      = Path.GetFileNameWithoutExtension(scriptAssetPath);
                }
            }


            GTEditorGUI.DrawObjectListEditor <RegisterToLuaObject>("Register Lua Object:",
                                                                   luaObjList, ref isLuaObjFoldout,
                                                                   OnDrawRegisterLuaObject, Color.red);

            EditorGUILayout.Space();
            GTEditorGUI.DrawObjectListEditor <RegisterToLuaObjectArr>("Register Lua Object Arr:",
                                                                      luaObjArrList, ref isLuaObjArrFoldout,
                                                                      OnDrawRegisterLuaObjectArr, Color.red);

            EditorGUILayout.Space();
            GTEditorGUI.DrawObjectListEditor <RegisterToLuaBehaviour>("Register Lua Behaviour:",
                                                                      luaBehList, ref isLuaBehFoldout,
                                                                      OnDrawRegisterLuaBehaviour, Color.red);

            EditorGUILayout.Space();
            GTEditorGUI.DrawObjectListEditor <RegisterToLuaBehaviourArr>("Register Lua Behaviour Arr:",
                                                                         luaBehArrList, ref isLuaBehArrFoldout,
                                                                         OnDrawRegisterLuaBehaviourArr, Color.red);
            if (GUI.changed)
            {
                behaviour.regLuaObject       = luaObjList.ToArray();
                behaviour.regLuaObjectArr    = luaObjArrList.ToArray();
                behaviour.regLuaBehaviour    = luaBehList.ToArray();
                behaviour.regLuaBehaviourArr = luaBehArrList.ToArray();
            }
        }
示例#27
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);
        }