当前位置:   article > 正文

使用 Sublime Text 2 开发 Unity3D 项目

sublime text能运用在unity吗

用 Sublime 已经有很长一段时间,很舒适,很贴心,根本停不下来。之前因为是开发页游,所以是用 AS3 开发,近段时间,新开了个手游项目,引擎方面选定了 Unity3D,老实说,之前没有太多的 3D 的概念,只是自己偶尔会下个 AS3 写的 3D 引擎玩一下,折腾折腾,并没有实际的工作中用到过相关的东西,如今项目需要用 Unity3D,有些兴奋,这可不是自己折腾的小打小闹了。

Unity 支持的脚本有3种:C#, JS, Boo,我们这边是打算使用 C#,在使用语言的问题上并没有做太多的讨论,一个是效率上,另一个是别的团队的成功经验,所以一开始就选定了 C#。Unity 自带了一个 IDE 叫 MonoDevelop,整个非常小清新的感觉,但遗憾的是,我用了一小段时间,发现非常难以适应,快捷键、效率、主题,以及编辑器的各种特性都让我用得很不舒服,换一套已经熟悉的操作习惯成本太高,无奈之下,只好 Sublime 上场了。

Google 了之后,发现使用 Sublime 来开发 Unity 的还是大有人大,经过一翻折腾,装上各种插件,写好各种配置后,大功告成。在写代码方面完全可以抛弃 MonoDevelop 了,当然断点调试还是需要它的,所以现在的工作台上这3个程序都得开着,Unity 负责场景编辑,Sublime 负责脚本编写,MonoDevelop 负责断点调试。

另外提一下, Sublime 中修改插件非常方便,你打开相应插件的目录,然后打开里面的 py 文件,你改,你保存,你看效果。

以下,就介绍一下我下载的各种插件以及配置。

Sublime 中 C# 注释快捷键

Sublime 注释的快捷键是 ctrl+/,对于不同的语言根据文件的扩展名会有不同的注释类型,不知道为什么这个快捷键在 C# 中似乎是失效了,也找到了解决方法,因为 C# 的注释和 JS 是一样的,所以把 JS 中关于注释那一块的 source 类型加上 cs 就好。具体的操作步骤如下:

1、打开 Sublime 的包目录,Preference -> Browse Packages ...
2、打开 JavaScript,找到 Comments.tmPreferences 并编辑
3、找到并编辑 <string>source.js, source.json, source.cs</string>

C# 语法分析

这个插件是重中之重,它会从 dll 文件中分析相关的类信息以及其他的元信息,然后你在编辑 cs 文件的时候,会在输入 . 的时候触发补全功能,根据不同的上下文,不同的变量,不同的类文件,会显示出相应的变量和方法提示列表,好用到暴!拉下来我们安装:

1、安装插件:CompleteSharp
2、编辑工程文件,工程文件是指扩展名为 *.sublime-project 的文件
3、在工程文件中加入如下相关的 dll 信息

{
    "folders":
    [
        {
            "path": "/D/Documents/Unity"
        }
    ],
    "settings":
    {
        "completesharp_assemblies": [
            "D:/Program Files (x86)/Unity/Editor/Data/Managed/UnityEngine.dll",
            "D:/Program Files (x86)/Unity/Editor/Data/Managed/UnityEditor.dll",
            "D:/Program Files (x86)/Unity/Editor/Data/Managed/nunit.framework.dll",
            "D:/Program Files (x86)/Unity/Editor/Data/Mono/lib/mono/unity/UnityScript.dll",
            "D:/Program Files (x86)/Unity/Editor/Data/Mono/lib/mono/unity/System.Core.dll",
            "D:/Program Files (x86)/Unity/Editor/Data/Mono/lib/mono/unity/System.dll",
            "D:/Documents/Unity/*/*/*/*/*.dll",
            "D:/Documents/Unity/*/*/*/*.dll"
        ]
    }
}
unity.sublime-project

配置文件图如下:

增强版的 All AutoComplete

基本上 All AutoComplete 可以算是必装的几个 Sublime 插件之一,不过我一直觉得 All AutoComplete 还是有点缺陷。按照插件的描述,All AutoComplete 会查询当前所有的标签页,并将分析其中的单词,然后在编辑的时候将合适的单词加入提示列表中。我说的缺陷在于,有一些单词对于我来说,是有必要每次都加入提示列表的,比如我自己有一个自己的代码库,里面就有很多自己写的类,类的例句也是我的风格,但如果要补全的话就需要打开相关的类文件,这是相当蛋疼的,所以一直有想改一下,改成 All AutoComplete 除了它自己分析的单词外,另外再加入我自定义的单词。

其实,这也算不上它的缺陷,只是我个人的的需求,我这个需求还有另外一个方法解决,就是建立相应的代码片断,有多少自定义的单词,就需要建立多少代码片断的文件,太麻烦了。

我试着改了一下 All AutoComplete,编辑 all_views_completions.py 文件,在其中 AllAutocomplete 中加入了一个 __init__ 方法,该方法会在插件初始化的时候去读取一个指定目录下的文件,指定目录下会有若干个文件,文件为一个以 '|' 为分隔符的单词的字符串,比如:Abs|AccelerationEvent,并将所有读取到的单词加入到 self.customs 中,然后在触发补全的方法中,将自定义的单词加入进去,大概效果效果如下(unity.txt 这份文件其实是从 Unity3D/UnityC#.tmLanguage 中扒过来的):

def __init__(self):
    words = []
    for root, dirs, files in os.walk("D:/Program Files/Sublime Text 2/Conf/Packages/All Autocomplete/custom"):
        for name in files:
            with open(os.path.join(root, name), "r") as file:
                words += file.read().split('|')

    words = filter_words2(words)
    self.customs = without_duplicates(words)
__init__

2015/10/14 修改:因为有一段时间没有高强度的用 Sublime 了,之前的版本也有点不太记得了,刚刚试了下,拿最新版本的 All Autocomplete 修改了一下,亲测可用,不过单词的读取就没有读文件了,有需要的同学自己修改一下吧:

  1 # Extends Sublime Text autocompletion to find matches in all open
  2 # files. By default, Sublime only considers words from the current file.
  3 
  4 import sublime_plugin
  5 import sublime
  6 import re
  7 import time
  8 from os.path import basename
  9 
 10 # limits to prevent bogging down the system
 11 MIN_WORD_SIZE = 3
 12 MAX_WORD_SIZE = 50
 13 
 14 MAX_VIEWS = 20
 15 MAX_WORDS_PER_VIEW = 100
 16 MAX_FIX_TIME_SECS_PER_VIEW = 0.01
 17 
 18 # custom words
 19 CUSTOM = ["ADBannerView","ADInterstitialAd","Abs","AcceptDrag","Acos","ActivateCurrentOffMeshLink","Add","AddBinaryData","AddClip","AddColor","AddComponent","AddComponentMenu","AddControl","AddCursorRect","AddDefaultControl","AddDisabledItem","AddEvent","AddExplosionForce","AddField","AddFloat","AddForce","AddForceAtPosition","AddFramesFromFile","AddIsValid","AddItem","AddKey","AddMatrix","AddMixingTransform","AddObjectToAsset","AddRange","AddRelativeForce","AddRelativeTorque","AddSeparator","AddTexture","AddTorque","AddTreeInstance","AddVector","AllocObject","AllocateViewID","AndroidJavaClass","AndroidJavaObject","AndroidJavaProxy","Angle","AngleAxis","AnimationClip","AnimationCurve","AnimationEvent","Apply","ApplyMaterialPropertyDrawers","ApplyModifiedProperties","ApplyTextureType","Approximately","AreStaticEditorFlagsSet","ArrayEquals","ArrowCap","Asin","AssetPathToGUID","Atan","Atan2","AttachCurrentThread","AttachToCollider","Authenticate","Authorize","Awake","Bake","BakeAsync","BakeLightProbesOnly","BakeLightProbesOnlyAsync","BakeMesh","BakeSelected","BakeSelectedAsync","Beep","Begin","BeginArea","BeginChangeCheck","BeginDisabledGroup","BeginGUI","BeginGroup","BeginHorizontal","BeginProperty","BeginSample","BeginScrollView","BeginToggleGroup","BeginVertical","BeginWindows","Blend","Blit","BlitMultiTap","BoneFromMuscle","Bounds","BoundsField","Box","Break","BringWindowToBack","BringWindowToFront","BroadcastMessage","BrowseURL","BuildAssetBundle","BuildAssetBundleExplicitAssetNames","BuildGenericAvatar","BuildHumanAvatar","BuildNavMesh","BuildNavMeshAsync","BuildPlayer","BuildStreamedSceneAssetBundle","Button","CacheProceduralProperty","CalcHeight","CalcLineTranslation","CalcMinMaxWidth","CalcScreenSize","CalcSize","CalculateFrustumPlanes","CalculateLODGroupBoundingBox","CalculatePath","CalculateTransformPath","CalculateTriangulation","Call","CallBooleanMethod","CallByteMethod","CallCharMethod","CallDoubleMethod","CallFloatMethod","CallIntMethod","CallLongMethod","CallObjectMethod","CallShortMethod","CallStatic","CallStaticBooleanMethod","CallStaticByteMethod","CallStaticCharMethod","CallStaticDoubleMethod","CallStaticFloatMethod","CallStaticIntMethod","CallStaticLongMethod","CallStaticObjectMethod","CallStaticShortMethod","CallStaticStringMethod","CallStaticVoidMethod","CallStringMethod","CallVoidMethod","CanStreamedLevelBeLoaded","Cancel","CancelAllLocalNotifications","CancelInvoke","CancelLocalNotification","CancelQuit","CapsuleCast","CapsuleCastAll","CaptureScreenshot","Ceil","CeilToInt","ChangeSetDescription","ChangeSetMove","ChangeSetStatus","ChangeSets","CheckCapsule","CheckSphere","Checkout","CheckoutIsValid","CircleCap","Clamp","Clamp01","ClampMagnitude","CleanCache","Clear","ClearAllNavMeshes","ClearArray","ClearCache","ClearCamera","ClearCorners","ClearCurves","ClearDeveloperConsole","ClearHostList","ClearLabels","ClearLocalNotifications","ClearParticles","ClearPlatformTextureSettings","ClearProgressBar","ClearRandomWriteTargets","ClearRemoteNotifications","ClearUndo","ClearWithSkybox","CloneMaterial","Close","CloseConnection","ClosestPointOnBounds","ClosestPointToArc","ClosestPointToDisc","ClosestPointToPolyLine","ClosestPowerOfTwo","CollapseUndoOperations","CollectDeepHierarchy","CollectDependencies","Color","Color32","ColorField","ColorProperty","Combine","CombineMeshes","CommandEvent","CompareTag","CompleteOffMeshLink","Compress","CompressTexture","Compute","ComputeBuffer","ComputeMD5Hash","ComputeSHA1Hash","ConeCap","Connect","Contains","ContextMenu","ConvertFromJNIArray","ConvertToJNIArray","Copy","CopyAsset","CopyCount","CopyFileOrDirectory","CopyFileOrDirectoryFollowSymlinks","CopyFrom","CopyFromSerializedProperty","CopyPropertiesFromMaterial","CopySerialized","CopyTo","Cos","CountInProperty","CountRemaining","Create","CreateAchievement","CreateAsset","CreateDirectory","CreateEditor","CreateEmptyPrefab","CreateExternalTexture","CreateFolder","CreateFromFile","CreateFromMemory","CreateGameObjectWithHideFlags","CreateInstance","CreateJNIArgArray","CreateJavaProxy","CreateJavaRunnable","CreateLeaderboard","CreateOrUpdateSecondary","CreatePrefab","CreatePrimitive","CreateTerrainGameObject","Cross","CrossFade","CrossFadeQueued","CubeCap","Cubemap","CurveField","CustomEditor","CustomPropertyDrawer","CylinderCap","DecreaseLevel","DefaultShaderProperty","Delete","DeleteAll","DeleteArrayElementAtIndex","DeleteAsset","DeleteChangeSets","DeleteChangeSetsIsValid","DeleteCommand","DeleteFileOrDirectory","DeleteGlobalRef","DeleteJNIArgArray","DeleteKey","DeleteLocalRef","DeleteSecondary","DeltaAngle","Destroy","DestroyImmediate","DestroyMaterial","DestroyObjectImmediate","DestroyPlayerObjects","DetachChildren","DetachCurrentThread","DetachFromCollider","DiffHead","DiffIsValid","DisableKeyword","Disc","DiscardContents","Disconnect","DisconnectPrefabInstance","Dispatch","DisplayCancelableProgressBar","DisplayDialog","DisplayDialogComplex","DisplayPopupMenu","DisplayProgressBar","DisplayWizard","Dispose","Distance","DistancePointBezier","DistancePointLine","DistancePointToLine","DistancePointToLineSegment","DistanceToArc","DistanceToCircle","DistanceToDisc","DistanceToLine","DistanceToPolyLine","DistanceToRectangle","DoesSourceTextureHaveAlpha","DoesSourceTextureHaveColor","DontDestroyOnLoad","Dot","DotCap","DragWindow","Draw","DrawAAPolyLine","DrawBezier","DrawCamera","DrawColorSwatch","DrawCube","DrawCursor","DrawCurveSwatch","DrawDefaultInspector","DrawFrustum","DrawGUITexture","DrawGizmo","DrawHeader","DrawIcon","DrawLine","DrawMesh","DrawMeshNow","DrawPolyLine","DrawPreviewTexture","DrawProcedural","DrawProceduralIndirect","DrawRay","DrawRegionSwatch","DrawSolidArc","DrawSolidDisc","DrawSolidRectangleWithOutline","DrawSphere","DrawTexture","DrawTextureAlpha","DrawTextureWithTexCoords","DrawWireArc","DrawWireCube","DrawWireDisc","DrawWireSphere","DrawWithTextSelection","DropDown","DropShadowLabel","DuplicateCommand","EaseInOut","Edit","Emit","EnableKeyword","Encapsulate","EncodeToPNG","End","EndArea","EndChangeCheck","EndDisabledGroup","EndGUI","EndGroup","EndHorizontal","EndProperty","EndSample","EndScrollView","EndToggleGroup","EndVertical","EndWindows","EnsureLocalCapacity","EnumMaskField","EnumPopup","Equal","EqualContents","EscapeURL","Euler","Evaluate","ExceptionClear","ExceptionDescribe","ExceptionOccurred","ExecuteMenuItem","Exists","Exit","Exp","Expand","ExpandHeight","ExpandWidth","ExportPackage","Expression","ExternalCall","ExternalEval","ExtractOggFile","FatalError","Filter","FilterChildren","FilterCount","Find","FindClass","FindClosestEdge","FindGameObjectsWithTag","FindIndex","FindKernel","FindObjectOfType","FindObjectsOfType","FindObjectsOfTypeAll","FindPrefabRoot","FindProperty","FindPropertyRelative","FindRootGameObjectWithSameParentPref","abFindStyle","FindTexture","FindValidUploadPrefabInstanceRoot","FindWithTag","FixedUpdate","FlexibleSpace","FloatField","FloatProperty","Floor","FloorToInt","Flush","Focus","FocusControl","FocusProjectWindow","FocusTextInControl","FocusWindow","FocusWindowIfItsOpen","Foldout","Font","ForceLOD","FormatBytes","FreeMoveHandle","FreeRotateHandle","FromBooleanArray","FromByteArray","FromCharArray","FromDoubleArray","FromFloatArray","FromIntArray","FromLongArray","FromMonoBehaviour","FromObjectArray","FromReflectedField","FromReflectedMethod","FromScriptableObject","FromShortArray","FromToRotation","GUIContent","GUIDToAssetPath","GUIPointToWorldRay","GUIStyle","GUIToScreenPoint","GameObject","GammaToLinearSpace","GenerateEditableFont","GenerateInBackground","GeneratePerTriangleUV","GenerateSecondaryUVSet","GenerateUniqueAssetPath","Get","GetAccelerationEvent","GetActiveConfigFields","GetActivePlugin","GetActivityIndicatorStyle","GetAllCurves","GetAlphamaps","GetAnimationClips","GetAnimationEvents","GetAnimationUpdateRate","GetAnimatorTransitionInfo","GetArrayElementAtIndex","GetArrayLength","GetAspectRect","GetAssetByGUID","GetAssetByPath","GetAssetListFromSelection","GetAssetOrScenePath","GetAssetPath","GetAtPath","GetAudioClip","GetAveragePing","GetAxis","GetAxisRaw","GetBlendShapeName","GetBlendShapeWeight","GetBoneTransform","GetBool","GetBooleanArrayElement","GetBooleanField","GetBuiltinSkin","GetButton","GetButtonDown","GetButtonUp","GetByteArrayElement","GetByteField","GetCachedIcon","GetCharArrayElement","GetCharField","GetCharacterInfo","GetChild","GetClass","GetClassName","GetClipCount","GetCollisionEvents","GetColor","GetColumn","GetComponent","GetComponentInChildren","GetComponents","GetComponentsInChildren","GetConstructorID","GetControlID","GetControlRect","GetCurrentAnimationClipState","GetCurrentAnimatorStateInfo","GetCurrentGroup","GetCursorPixelPosition","GetCursorStringIndex","GetDSPBufferSize","GetData","GetDefaultPropertyHeight","GetDependencies","GetDetailLayer","GetDeviceCaps","GetDistanceToPoint","GetDoubleArrayElement","GetDoubleField","GetDragAndDropTitle","GetEditorCurve","GetEndProperty","GetEnumerator","GetFieldID","GetFiltered","GetFloat","GetFloatArrayElement","GetFloatField","GetFloatValue","GetGPUProjectionMatrix","GetGenerateAllOutputs","GetGeneratedTexture","GetGeneratedTextures","GetGenericData","GetGroundHit","GetHandleSize","GetHeight","GetHeights","GetIKPosition","GetIKPositionWeight","GetIKRotation","GetIKRotationWeight","GetIconSize","GetIconSizesForTargetGroup","GetIconsForTargetGroup","GetIgnoreLayerCollision","GetIndices","GetInfoString","GetInspectorTitle","GetInstanceID","GetInt","GetIntArrayElement","GetIntField","GetInteger","GetInterpolatedHeight","GetInterpolatedLightProbe","GetInterpolatedNormal","GetItemCount","GetIterator","GetJoystickNames","GetKey","GetKeyDown","GetKeyUp","GetLabels","GetLastPing","GetLastRect","GetLatest","GetLatestIsValid","GetLayerCost","GetLayerName","GetLayerWeight","GetLocalNotification","GetLongArrayElement","GetLongField","GetMaterialCount","GetMaterialOffset","GetMaterialProperties","GetMaterialProperty","GetMaterialScale","GetMaterials","GetMatrix","GetMethodID","GetMonoHeapSize","GetMonoUsedSize","GetMouseButton","GetMouseButtonDown","GetMouseButtonUp","GetMuscleDefaultMax","GetMuscleDefaultMin","GetNameOfFocusedControl","GetNativeTextureID","GetNativeTexturePtr","GetNavMeshLayer","GetNavMeshLayerFromName","GetNavMeshLayerNames","GetNextAnimationClipState","GetNextAnimatorStateInfo","GetObjectArrayElement","GetObjectClass","GetObjectEnabled","GetObjectField","GetObjectPickerControlID","GetObjectPickerObject","GetOutputData","GetParticles","GetPath","GetPixel","GetPixelBilinear","GetPixels","GetPixels32","GetPlatformTextureSettings","GetPoint","GetPointVelocity","GetPosition","GetPostprocessOrder","GetPrefabObject","GetPrefabParent","GetPrefabType","GetPreviewTitle","GetProceduralBoolean","GetProceduralColor","GetProceduralEnum","GetProceduralFloat","GetProceduralOutputType","GetProceduralPropertyDescriptions","GetProceduralTexture","GetProceduralVector","GetPropertyCount","GetPropertyDescription","GetPropertyHeight","GetPropertyModifications","GetPropertyName","GetPropertyType","GetPrototypeNames","GetQualityLevel","GetRangeLimits","GetRawClass","GetRawObject","GetRayIntersection","GetRayIntersectionAll","GetRayIntersectionNonAlloc","GetRect","GetRelativePointVelocity","GetRemoteNotification","GetRow","GetRuntimeMemorySize","GetScreenRect","GetScriptingDefineSymbolsForGroup","GetSecondaries","GetSecondary","GetSecondaryTouch","GetShortArrayElement","GetShortField","GetSide","GetSignature","GetSpectrumData","GetStateObject","GetStatic","GetStaticBooleanField","GetStaticByteField","GetStaticCharField","GetStaticDoubleField","GetStaticEditorFlags","GetStaticFieldID","GetStaticFloatField","GetStaticIntField","GetStaticLongField","GetStaticMethodID","GetStaticObjectField","GetStaticShortField","GetStaticStringField","GetSteepness","GetStreamProgressForLevel","GetString","GetStringField","GetStringUTFChars","GetStringUTFLength","GetStyle","GetSuperclass","GetSupportedLayers","GetTag","GetTemplate","GetTemporary","GetTexDim","GetTextMetaDataPathFromAssetPath","GetTexture","GetTextureAlphaSource","GetTextureOffset","GetTextureScale","GetTopology","GetTotalPointCount","GetTouch","GetTransforms","GetTriangles","GetTypeForControl","GetUniqueTempPathInProject","GetVector","GetVersion","GetWindow","GetWindowWithRect","Gradient","GradientAlphaKey","GradientColorKey","HSVToRGB","HandlePrefixLabel","HasAspectRatio","HasCameraPermissions","HasCharacter","HasGPSPermissions","HasHelpForObject","HasIdentificationPermissions","HasKey","HasMicrophonePermissions","HasObjectThumbnail","HasPreviewGUI","HasProLicense","HasProceduralProperty","HasProperty","HasSharedPermissions","HasUserAuthorization","HavePublicAddress","Height","HelpBox","Hide","Highlight","HighlightIdentifier","HitTest","HorizontalScrollbar","HorizontalSlider","IgnoreCollision","IgnoreLayerCollision","Import","ImportAsset","ImportPackage","InAnimationMode","Incoming","IncomingChangeSetAssets","IncreaseLevel","IncrementCurrentGroup","IndexOf","InitializeSecurity","InitializeServer","Insert","InsertArrayElementAtIndex","InspectorTitlebar","InstanceIDToObject","Instantiate","InstantiateAttachedAsset","InstantiateMaterial","InstantiatePrefab","IntField","IntPopup","IntSlider","InterruptMatchTarget","IntersectRay","Intersects","InvalidateState","Inverse","InverseLerp","InverseTransformDirection","InverseTransformPoint","Invoke","InvokeOnAppThread","InvokeOnUIThread","InvokeRepeating","IsAlive","IsAssignableFrom","IsAvailable","IsAwake","IsChildOf","IsCreated","IsInTransition","IsInstanceOf","IsInvoking","IsMainAsset","IsName","IsOneOfStates","IsOpenForEdit","IsParameterControlledByCurve","IsPersistent","IsPlaying","IsPowerOfTwo","IsProceduralPropertyCached","IsPropertyAnimated","IsRecording","IsSameObject","IsShaderPropertyHidden","IsSleeping","IsState","IsSubAsset","IsTag","IsUserName","IsVersionCached","IssuePluginEvent","KeyboardEvent","Keyframe","LOD","Label","LabelField","LastIndexOf","LateUpdate","LayerField","LayerMask","LayerToName","Lerp","LerpAngle","Linear","LinearToGammaSpace","Linecast","LinecastAll","LinecastNonAlloc","Load","LoadAchievementDescriptions","LoadAchievements","LoadAll","LoadAllAssetRepresentationsAtPath","LoadAllAssetsAtPath","LoadAssetAtPath","LoadAsync","LoadFriends","LoadFromCacheOrDownload","LoadIdentity","LoadImage","LoadImageIntoTexture","LoadLevel","LoadLevelAdditive","LoadLevelAdditiveAsync","LoadLevelAsync","LoadMainAssetAtPath","LoadOrtho","LoadPixelMatrix","LoadProjectionMatrix","LoadRequired","LoadScores","LoadUnityWeb","LoadUsers","LocalNotification","Lock","LockIsValid","LockReloadAssemblies","Log","Log10","LogError","LogException","LogWarning","LookAt","LookLikeControls","LookRotation","MarkAsUsed","MarkDynamic","MarkNonReadable","MarkRestoreExpected","MaskField","MatchTarget","MatchTargetWeightMask","Material","Max","MaxHeight","MaxWidth","MenuCommand","MenuItem","Merge","MergeAllPrefabInstances","Mesh","Min","MinHeight","MinMaxRect","MinMaxSlider","MinWidth","ModalWindow","Move","MoveArrayElement","MoveAsset","MoveAssetToTrash","MoveFileOrDirectory","MoveKey","MovePosition","MoveRotation","MoveTowards","MoveTowardsAngle","MultMatrix","MultiTexCoord","MultiTexCoord2","MultiTexCoord3","MultiplyPoint","MultiplyPoint3x4","MultiplyVector","MuscleFromBone","NameToLayer","NavMeshPath","NewBooleanArray","NewByteArray","NewCharArray","NewDoubleArray","NewFloatArray","NewGlobalRef","NewIntArray","NewLocalRef","NewLongArray","NewObject","NewObjectArray","NewScene","NewShortArray","NewStringUTF","Next","NextPowerOfTwo","NextVisible","NicifyVariableName","Normalize","ObjectContent","ObjectField","OnAnimatorIK","OnAnimatorMove","OnApplicationFocus","OnApplicationPause","OnApplicationQuit","OnAssignMaterialModel","OnAudioFilterRead","OnBecameInvisible","OnBecameVisible","OnCollisionEnter","OnCollisionEnter2D","OnCollisionExit","OnCollisionExit2D","OnCollisionStay","OnCollisionStay2D","OnConnectedToServer","OnControllerColliderHit","OnDestroy","OnDidOpenScene","OnDisable","OnDisconnectedFromServer","OnDrawGizmos","OnDrawGizmosSelected","OnEnable","OnFailedToConnect","OnFailedToConnectToMasterServer","OnFocus","OnGUI","OnGroupAtlases","OnHierarchyChange","OnInspectorGUI","OnInspectorUpdate","OnInteractivePreviewGUI","OnJointBreak","OnLevelWasLoaded","OnLostFocus","OnMasterServerEvent","OnMouseDown","OnMouseDrag","OnMouseEnter","OnMouseExit","OnMouseOver","OnMouseUp","OnMouseUpAsButton","OnNetworkInstantiate","OnParticleCollision","OnPlayerConnected","OnPlayerDisconnected","OnPostRender","OnPostprocessAllAssets","OnPostprocessAudio","OnPostprocessGameObjectWithUserProperties","OnPostprocessModel","OnPostprocessTexture","OnPreCull","OnPreRender","OnPreprocessAudio","OnPreprocessModel","OnPreprocessTexture","OnPreviewGUI","OnPreviewSettings","OnProjectChange","OnRenderImage","OnRenderObject","OnSceneGUI","OnSelectionChange","OnSerializeNetworkView","OnServerInitialized","OnShaderModified","OnTriggerEnter","OnTriggerEnter2D","OnTriggerExit","OnTriggerExit2D","OnTriggerStay","OnTriggerStay2D","OnValidate","OnWillCreateAsset","OnWillDeleteAsset","OnWillMoveAsset","OnWillRenderObject","OnWillSaveAssets","OnWizardCreate","OnWizardOtherButton","OnWizardUpdate","Open","OpenAsset","OpenFilePanel","OpenFolderPanel","OpenProject","OpenScene","OpenSceneAdditive","OpenURL","Optimize","Ortho","OrthoNormalize","OverlapArea","OverlapAreaAll","OverlapAreaNonAlloc","OverlapCircle","OverlapCircleAll","OverlapCircleNonAlloc","OverlapPoint","OverlapPointAll","OverlapPointNonAlloc","OverlapSphere","PackTextures","PasswordField","Pause","PerformRedo","PerformUndo","PeriodicBadgeUpdate","PeriodicUpdate","PerlinNoise","Perspective","PhysicMaterial","PickGameObject","PickRectObjects","Ping","PingObject","PingPong","Plane","Play","PlayClipAtPoint","PlayDelayed","PlayFullScreenMovie","PlayOneShot","PlayQueued","PlayScheduled","PointOnLineParameter","PollHostList","PopAssetDependencies","PopCamera","PopLocalFrame","PopMatrix","Popup","PositionHandle","Pow","PreferenceItem","PrefetchSocketPolicy","PrefixLabel","PrepareStartDrag","PresentLocalNotificationNow","ProgressBar","Project","ProjectPointLine","PropertiesChanged","PropertiesGUI","PropertyField","PropertyToID","PushAssetDependencies","PushCamera","PushLocalFrame","PushMatrix","Quaternion","QueryStateObject","QueueGameViewInputEvent","Quit","RGBToHSV","RPC","RadiusHandle","Range","RangeProperty","Ray","RaySnap","Raycast","RaycastAll","RaycastNonAlloc","ReadAllBytes","ReadPixels","ReadTextureImportInstructions","ReadTextureSettings","RebuildTextures","RebuildTexturesImmediately","RecalculateBounds","RecalculateNormals","ReconnectToLastPrefab","RecordObject","RecordObjects","RecordPrefabInstancePropertyModifications","Rect","RectField","RectOffset","Reflect","Refresh","RefreshPrototypes","RegisterCreatedObjectUndo","RegisterForRemoteNotificationTypes","RegisterHost","RegisterLogCallback","RegisterLogCallbackThreaded","RegisterPropertyChangeUndo","Release","ReleaseTemporary","ReloadAd","Remove","RemoveAll","RemoveAt","RemoveBadge","RemoveClip","RemoveKey","RemoveMixingTransform","RemoveNotification","RemoveRPCs","RemoveRPCsInGroup","RenameAsset","RenameMaterial","Render","RenderGameViewCameras","RenderStaticPreview","RenderTexture","RenderToCubemap","RenderWithShader","Repaint","RepaintHierarchyWindow","RepaintProjectWindow","Repeat","RepeatButton","ReplaceDirectory","ReplaceFile","ReplacePrefab","ReportProgress","ReportScore","RequestCharactersInTexture","RequestHostList","RequestUserAuthorization","RequireComponent","RequiredBone","Reset","ResetAllAchievements","ResetAspect","ResetInputAxes","ResetMaterial","ResetNoBackupFlag","ResetPath","ResetProjectionMatrix","ResetReplacementShader","ResetToPrefabState","ResetWorldToCameraMatrix","Resize","Resolve","ResolveIsValid","Resume","Revert","RevertAllDownToGroup","RevertAllInCurrentGroup","RevertIsValid","RevertPrefabInstance","Rewind","Rotate","RotateAround","RotateAroundPivot","RotateTowards","RotationHandle","Round","RoundToInt","RunningOnAppThread","RunningOnUIThread","SameSide","Sample","SampleAnimation","SampleAnimationClip","SampleHeight","SamplePathPosition","SamplePosition","Save","SaveAssets","SaveCurrentSceneIfUserWantsTo","SaveFilePanel","SaveFilePanelInProject","SaveFolderPanel","SaveScene","Scale","ScaleAroundPivot","ScaleHandle","ScaleSlider","ScaleValueHandle","ScheduleLocalNotification","ScreenPointToRay","ScreenToGUIPoint","ScreenToViewportPoint","ScreenToWorldPoint","ScrollTo","SecondaryTileData","SelectableLabel","SelectionFrame","SelectionGrid","SendEvent","SendMessage","SendMessageUpwards","Serialize","SerializedObject","Set","Set3Points","SetActive","SetActivityIndicatorStyle","SetAlphamaps","SetAnimationClips","SetAnimationEvents","SetAnimationUpdateRate","SetAspectRatio","SetBlendShapeWeight","SetBool","SetBooleanArrayElement","SetBooleanField","SetBuffer","SetByteArrayElement","SetByteField","SetCamera","SetCameraPermissions","SetCharArrayElement","SetCharField","SetColor","SetColors","SetColumn","SetCompletionAction","SetCursor","SetCurve","SetDSPBufferSize","SetData","SetDefaults","SetDensity","SetDestination","SetDetailLayer","SetDetailResolution","SetDirty","SetDoubleArrayElement","SetDoubleField","SetEditorCurve","SetEnabledFading","SetFloat","SetFloatArrayElement","SetFloatField","SetFloats","SetFromToRotation","SetGPSPermissions","SetGenerateAllOutputs","SetGenericData","SetGlobalAnisotropicFilteringLimits","SetGlobalColor","SetGlobalFloat","SetGlobalMatrix","SetGlobalShaderProperty","SetGlobalTexture","SetGlobalVector","SetHeights","SetIKPosition","SetIKPositionWeight","SetIKRotation","SetIKRotationWeight","SetIconSize","SetIconsForTargetGroup","SetIdentificationPermissions","SetIndices","SetInt","SetIntArrayElement","SetIntField","SetInteger","SetInts","SetIsDifferentCacheDirty","SetKeys","SetLODS","SetLabels","SetLayerCost","SetLayerWeight","SetLevelPrefix","SetLongArrayElement","SetLongField","SetLookAtPosition","SetLookAtWeight","SetLookRotation","SetMaterialOffset","SetMaterialScale","SetMatrix","SetMicrophonePermissions","SetMinMax","SetNameSmart","SetNavMeshLayer","SetNeighbors","SetNextControlName","SetNoBackupFlag","SetNormalAndPosition","SetObjectArrayElement","SetObjectEnabled","SetObjectField","SetParticles","SetPass","SetPath","SetPerTriangleUV2","SetPixel","SetPixels","SetPixels32","SetPlatformTextureSettings","SetPosition","SetProceduralBoolean","SetProceduralColor","SetProceduralEnum","SetProceduralFloat","SetProceduralTexture","SetProceduralVector","SetPropertyBlock","SetPropertyModifications","SetQualityLevel","SetRandomWriteTarget","SetReceivingEnabled","SetRenderTarget","SetRenderingResolution","SetReplacementShader","SetResolution","SetRevertBackfacing","SetRow","SetScheduledEndTime","SetScheduledStartTime","SetScope","SetScriptingDefineSymbolsForGroup","SetSelectedWireframeHidden","SetSendingEnabled","SetShader","SetSharedPermissions","SetShortArrayElement","SetShortField","SetStatic","SetStaticBooleanField","SetStaticByteField","SetStaticCharField","SetStaticDoubleField","SetStaticEditorFlags","SetStaticFloatField","SetStaticIntField","SetStaticLongField","SetStaticObjectField","SetStaticShortField","SetStaticStringField","SetString","SetStringField","SetTRS","SetTarget","SetTargetBuffers","SetTexture","SetTextureAlphaSource","SetTextureOffset","SetTextureScale","SetTextureSettings","SetTransformParent","SetTriangles","SetTrigger","SetUserFilter","SetVector","SetVertexCount","SetWidth","ShaderProperty","Show","ShowAchievementsUI","ShowAsContext","ShowAsDropDown","ShowAuxWindow","ShowDefaultAchievementCompletionBanner","ShowHelpForObject","ShowHelpPage","ShowLeaderboardUI","ShowNotification","ShowObjectPicker","ShowPopup","ShowUtility","Sign","SimpleMove","Simulate","Sin","Sleep","Slerp","Slider","Slider2D","SmoothDamp","SmoothDampAngle","SmoothEdges","SmoothStep","SmoothTangents","SnapValue","Space","SphereCap","SphereCast","SphereCastAll","SqrDistance","Sqrt","Start","StartActivityIndicator","StartAnimationMode","StartAssetEditing","StartCoroutine","StartDrag","StartPlayback","StartRecording","Statement","Status","Step","Stop","StopActivityIndicator","StopAllCoroutines","StopAnimationMode","StopAssetEditing","StopCoroutine","StopPeriodicBadgeUpdate","StopPeriodicUpdate","StopPlayback","StopRebuilds","StopRecording","StringToHash","Submit","SubmitIsValid","SupportsRenderTextureFormat","SupportsStencil","SweepTest","SweepTestAll","TRS","TagField","Tan","TestConnection","TestConnectionNAT","TestPlanesAABB","Tetrahedralize","TexCoord","TexCoord2","TexCoord3","TextArea","TextField","Texture2D","Texture3D","TextureProperty","Throw","ThrowNew","ToAngleAxis","ToBooleanArray","ToByteArray","ToCharArray","ToDoubleArray","ToFloatArray","ToIntArray","ToLongArray","ToObjectArray","ToReflectedField","ToReflectedMethod","ToShortArray","ToString","Toggle","ToggleLeft","Toolbar","TransformDirection","TransformPoint","Translate","UnEscapeURL","UnfocusWindow","Unload","UnloadAsset","UnloadUnusedAssets","UnloadUnusedAssetsIgnoreManagedReferences","UnlockIsValid","UnlockReloadAssemblies","UnregisterForRemoteNotifications","UnregisterHost","Update","UpdateBadgeImage","UpdateBadgeNumber","UpdateExternalTexture","UpdateIfDirtyOrScript","UpdatePositions","UpdateSettings","Use","UseDefaultMargins","ValidateMoveAsset","Vector2Field","Vector3FieldVector4Field","VectorProperty","Vertex","Vertex3","VerticalScrollbar","VerticalSlider","Vibrate","Viewport","ViewportPointToRay","ViewportToScreenPoint","ViewportToWorldPoint","WWW","WWWForm","Wait","WaitForSeconds","WakeUp","WarmupAllShaders","Warp","WebCamTexture","Width","Window","WorldPointToSizedRect","WorldToGUIPoint","WorldToScreenPoint","WorldToViewportPoint","WriteAllBytes","WriteImportSettingsIfDirty","bool","print"]
 20 
 21 
 22 class AllAutocomplete(sublime_plugin.EventListener):
 23 
 24     def on_query_completions(self, view, prefix, locations):
 25         words = []
 26         # Limit number of views but always include the active view. This
 27         # view goes first to prioritize matches close to cursor position.
 28         other_views = [v for v in sublime.active_window().views() if v.id != view.id]
 29         views = [view] + other_views
 30         views = views[0:MAX_VIEWS]
 31 
 32         for v in views:
 33             if len(locations) > 0 and v.id == view.id:
 34                 view_words = v.extract_completions(prefix, locations[0])
 35             else:
 36                 view_words = v.extract_completions(prefix)
 37             view_words = filter_words(view_words)
 38             view_words = fix_truncation(v, view_words)
 39             words += [(w, v) for w in view_words]
 40 
 41         # add custom words
 42         words += [(w, view) for w in CUSTOM if is_completion(prefix, w)]
 43 
 44         words = without_duplicates(words)
 45         matches = []
 46         for w, v in words:
 47             trigger = w
 48             contents = w.replace('$', '\\$')
 49             if v.id != view.id and v.file_name():
 50                 trigger += '\t(%s)' % basename(v.file_name())
 51             matches.append((trigger, contents))
 52 
 53         return matches
 54 
 55 
 56 def filter_words(words):
 57     words = words[0:MAX_WORDS_PER_VIEW]
 58     return [w for w in words if MIN_WORD_SIZE <= len(w) <= MAX_WORD_SIZE]
 59 
 60 
 61 # keeps first instance of every word and retains the original order
 62 # (n^2 but should not be a problem as len(words) <= MAX_VIEWS*MAX_WORDS_PER_VIEW)
 63 def without_duplicates(words):
 64     result = []
 65     used_words = []
 66     for w, v in words:
 67         if w not in used_words:
 68             used_words.append(w)
 69             result.append((w, v))
 70     return result
 71 
 72 
 73 # Ugly workaround for truncation bug in Sublime when using view.extract_completions()
 74 # in some types of files.
 75 def fix_truncation(view, words):
 76     fixed_words = []
 77     start_time = time.time()
 78 
 79     for i, w in enumerate(words):
 80         #The word is truncated if and only if it cannot be found with a word boundary before and after
 81 
 82         # this fails to match strings with trailing non-alpha chars, like
 83         # 'foo?' or 'bar!', which are common for instance in Ruby.
 84         match = view.find(r'\b' + re.escape(w) + r'\b', 0)
 85         truncated = is_empty_match(match)
 86         if truncated:
 87             #Truncation is always by a single character, so we extend the word by one word character before a word boundary
 88             extended_words = []
 89             view.find_all(r'\b' + re.escape(w) + r'\w\b', 0, "$0", extended_words)
 90             if len(extended_words) > 0:
 91                 fixed_words += extended_words
 92             else:
 93                 # to compensate for the missing match problem mentioned above, just
 94                 # use the old word if we didn't find any extended matches
 95                 fixed_words.append(w)
 96         else:
 97             #Pass through non-truncated words
 98             fixed_words.append(w)
 99 
100         # if too much time is spent in here, bail out,
101         # and don't bother fixing the remaining words
102         if time.time() - start_time > MAX_FIX_TIME_SECS_PER_VIEW:
103             return fixed_words + words[i+1:]
104 
105     return fixed_words
106 
107 
108 def is_completion(trigger, content):
109     trigger = trigger.lower()
110     content = content.lower()
111     ci = 0
112     cl = len(content)
113     ti = 0
114     tl = len(trigger)
115     while True:
116         if content[ci] == trigger[ti]:
117             ti = ti + 1
118         ci = ci + 1
119         if ti == tl:
120             return True
121         if ci == cl:
122             return False
123 
124 
125 if sublime.version() >= '3000':
126     def is_empty_match(match):
127         return match.empty()
128 else:
129     def is_empty_match(match):
130         return match is None
All Autocomplete

 

Unity3D 脚本参考

写代码的过程中,经常会需要查 API 文档,所以方便的查 API 文档是一个重要的功能。Sublime 本身并不提供类似的功能,但这难不倒各位程序员童鞋,我在网上找到一个插件:Unity3D Script Reference Search,这个插件的作用就是搜索 API,可以搜索当前光标上的单词,也可以输入指定的内容。这个插件干的事情非常简单,其实就是在插件中调用 webbrowser.open_new_tab(url) ,其中 url 就是拼成的一个查询链接。不过这个插件访问的 url 却是官网的在线 API,而实际上在本地是也有一份 API 文档的,通过 Unity 菜单 Help -> Scripting Reference 可以访问。

我试着改了一下插件,修改 Unity3DScriptReference.py 文件,将其中的 url 链接改成指向本地的文件,似乎并不生效,web 这一块我不熟悉,所以我干脆简单点,用 Python 开一个简单的 http 服务,我在 使用Python创建简单的HTTP和FTP服务 中有介绍,直接在 Unity 目录下面开一个 http 服务,最终的效果图如下:

2014/5/23 修改:因为有先入为主的想法,以为只能用 webbrowser 来访问网页,实际上是不需要的,http 服务也是没必要开的,上面的代码只要改一下就可以,将 webbrowser.open_new_tab 改成 subprocess.call 就可以了,如下:

browser = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe "

def SearchUnityScriptReferenceFor(text):
    # url = 'http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=' + text.replace(' ','%20')
    url = 'file:///D:/Program%20Files%20(x86)/Unity/Editor/Data/Documentation/Documentation/ScriptReference/30_search.html?q=' + text.replace(' ','%20')
    # webbrowser.open_new_tab(url)
    subprocess.call(browser+url)

def OpenUnityFunctionReference(text):
    # url = 'http://unity3d.com/support/documentation/ScriptReference/' + text.replace(' ','%20')
    url = 'file:///D:/Program%20Files%20(x86)/Unity/Editor/Data/Documentation/Documentation/ScriptReference/' + text.replace(' ','%20') + '.html'
    # webbrowser.open_new_tab(url)
    subprocess.call(browser+url)

接着,可以绑定快捷键,ctrl+shift+p -> key bindings user,添加如下快捷键:

{ "keys": ["f4"], "command": "unity_reference_search_selection" }

Unity 语法高亮以及代码片

Unity 提供了一整套完善的游戏开发套件,在写代码的过程中,会遇到很多类是 Unity 自带的,有些类则是 C# 语言本身支持的,为此,网上有达人做了一份 Unity C# 语言高亮文件,里面会将 Unity 自带的类进行单独的高亮。不过我并不喜欢那个高亮的颜色,所以我自己并没有用,插件名称:Unity3D。

同语法高亮类似,也有达人做了一份为 Unity 量身打造的代码片断插件,下载安装相应的插件即中:Unity3D Snippets and Completes。

还有一个神奇的插件:Unity Completions,为什么说神奇呢,因为这个插件我安装就花了1个多小时,安装完后发现整个目录占用了200多M,文件大小20多M,光看这个要吓尿了,其他插件能有顶多有个几百K而已,再看看文件,大概有7W多个,怪不得占用这么大,但老实说这个插件我试了一下之后并不觉得好用,有兴趣的童鞋可以试试。

参考文章

用sublime text2寫unity3d c# script
Unity completions for Sublime Text
Using Sublime Text 2 With Unity3D
Using Sublime Text 2 With Unity3D – Part 2
Using Unity with Sublime Text 2 (How to get everything set up)

欢迎补充~

转载于:https://www.cnblogs.com/yili16438/p/3721896.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/天景科技苑/article/detail/810510
推荐阅读
相关标签
  

闽ICP备14008679号