Пример #1
0
        bool CreateNewAsset()
        {
            string assetPathAndName = EditorUtility.SaveFilePanelInProject("Choose Kinematica Asset filename",
                                                                           string.Empty, k_KinematicaBinaryExtension, string.Empty,
                                                                           ScriptableObjectUtility.GetSelectedPathOrFallback());

            if (!string.IsNullOrEmpty(assetPathAndName))
            {
                assetPathAndName = Path.ChangeExtension(assetPathAndName, ".asset");

                var asset = CreateInstance <Asset>();

                AssetDatabase.CreateAsset(asset, assetPathAndName);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                EditorUtility.FocusProjectWindow();

                Asset = asset;

                return(true);
            }

            return(false);
        }