本文整理汇总了C#中Platform.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Platform.ToString方法的具体用法?C# Platform.ToString怎么用?C# Platform.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Platform
的用法示例。
在下文中一共展示了Platform.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyLocalPosition
public void ApplyLocalPosition(Platform platform) {
#if UNITY_4_6
var rectTransform = GetComponent<RectTransform>();
#endif
if(localPositionPerPlatform != null) {
foreach(LocalPositionPerPlatform pair in localPositionPerPlatform) {
if (isCompatiblePlatform(platform, pair.platform)) {
#if UNITY_4_6
if (rectTransform != null) rectTransform.localPosition = pair.localPosition;
else transform.localPosition = pair.localPosition;
#else
transform.localPosition = pair.localPosition;
#endif
break;
}
}
}
if(Platforms.IsPlatformAspectBased(platform.ToString()) && localPositionPerAspectRatio != null) {
foreach(LocalPositionPerAspectRatio pair in localPositionPerAspectRatio) {
if(AspectRatios.GetAspectRatio() == pair.aspectRatio) {
#if UNITY_4_6
if (rectTransform != null) rectTransform.localPosition = pair.localPosition;
else transform.localPosition = pair.localPosition;
#else
transform.localPosition = pair.localPosition;
#endif
break;
}
}
}
// if an anchor position, it will override others
#if UNITY_4_6
if(anchorPositions != null && rectTransform == null) {
#else
if(anchorPositions != null) {
#endif
foreach(AnchorPosition pair in anchorPositions) {
// make sure we have a camera to align to
var cam = pair.alignmentCamera;
if (cam == null)
{
Debug.LogError("No alignment camera is attached to GameObject: " + gameObject.name);
continue;
}
// get screen size
float screenWidth = Screen.width, screenHeight = Screen.height;
#if UNITY_EDITOR
if (UseEditorApplyMode) AspectRatios.getScreenSizeHack(out screenWidth, out screenHeight);
#endif
// get position
var pos = pair.screenPosition;
if (pair.positionXAsPercent)
pos.x *= screenWidth;// * 0.01f;
if (pair.positionYAsPercent)
pos.y *= screenHeight;// * 0.01f;
// global calculations
var ray = cam.ScreenPointToRay(pos);
var planePoint = RayInersectPlane(ray, -cam.transform.forward, transform.position);
ray = cam.ScreenPointToRay(Vector3.zero);
var bottomLeft = RayInersectPlane(ray, -cam.transform.forward, transform.position);
ray = cam.ScreenPointToRay(new Vector3(screenWidth, screenHeight, 0));
var topRight = RayInersectPlane(ray, -cam.transform.forward, transform.position);
// get object radius
float radius = 0;
var renderer = GetComponent<Renderer>();
if (renderer != null) radius = (renderer.bounds.max - renderer.bounds.min).magnitude * .5f;
// get new projected width and height
var screenSize = (topRight - bottomLeft);
screenWidth = Vector3.Dot(screenSize, cam.transform.right);
screenHeight = Vector3.Dot(screenSize, cam.transform.up);
// horizontal alignment types
switch (pair.horizontalAlignment)
{
case HorizontalAlignments.Left: planePoint += cam.transform.right * (!pair.centerX ? radius : 0); break;
case HorizontalAlignments.Right: planePoint += cam.transform.right * (screenWidth - (!pair.centerX ? radius : 0)); break;
case HorizontalAlignments.Center: planePoint += cam.transform.right * (screenWidth * .5f); break;
}
// vertical alignment types
switch (pair.verticalAlignment)
{
case VerticalAlignments.Bottom: planePoint += cam.transform.up * (!pair.centerY ? radius : 0); break;
case VerticalAlignments.Top: planePoint += cam.transform.up * (screenHeight - (!pair.centerY ? radius : 0)); break;
case VerticalAlignments.Center: planePoint += cam.transform.up * (screenHeight * .5f); break;
}
// set final position
transform.position = planePoint;
//.........这里部分代码省略.........
示例2: VerifyEmitWithNoResources
private void VerifyEmitWithNoResources(CSharpCompilation comp, Platform platform)
{
var options = TestOptions.ReleaseExe.WithPlatform(platform);
CompileAndVerify(comp.WithAssemblyName("EmitWithNoResourcesAllPlatforms_" + platform.ToString()).WithOptions(options));
}
示例3: ApplyLocalScale
public void ApplyLocalScale(Platform platform) {
#if UNITY_4_6
var rectTransform = GetComponent<RectTransform>();
#endif
if(localScalePerPlatform != null) {
foreach(LocalScalePerPlatform pair in localScalePerPlatform) {
if (isCompatiblePlatform(platform, pair.platform)) {
#if UNITY_4_6
if (rectTransform != null) rectTransform.localScale = pair.localScale;
else transform.localScale = pair.localScale;
#else
transform.localScale = pair.localScale;
#endif
break;
}
}
}
if(Platforms.IsPlatformAspectBased(platform.ToString()) && localScalePerAspectRatio != null) {
foreach(LocalScalePerAspectRatio pair in localScalePerAspectRatio) {
if(AspectRatios.GetAspectRatio() == pair.aspectRatio) {
#if UNITY_4_6
if (rectTransform != null) rectTransform.localScale = pair.localScale;
else transform.localScale = pair.localScale;
#else
transform.localScale = pair.localScale;
#endif
break;
}
}
}
}
示例4: PlatformSpecificChanges
//=====
//Run through all of the scenes (working on duplicates) and make changes specified in PlatformSpecifics BEFORE building
//=====
public static void PlatformSpecificChanges(Platform platform, bool stripMaterials)
{
//Set platform override to the specified platform during the platform-specific changes, but revert back
//to the platform that was originally set at the end
string previousPlatformOverride = EditorPrefs.GetString (Platforms.editorPlatformOverrideKey, "Standalone");
EditorPrefs.SetString (Platforms.editorPlatformOverrideKey, platform.ToString ());
//Make sure to use the proper array of scenes, specified at the top of the file
if (platform == Platform.WebPlayer)
levels = webPlayerScenes;
else if (platform == Platform.iPhone)
levels = iPhoneScenes;
else if (platform == Platform.iPad)
levels = iPadScenes;
else if (platform == Platform.Android)
levels = androidScenes;
else if (platform == Platform.FlashPlayer)
levels = flashPlayerScenes;
else if (platform == Platform.NaCl)
levels = naClScenes;
#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_1
else if (platform == Platform.WP8)
levels = winPhoneScenes;
else if (platform == Platform.Windows8)
levels = windows8Scenes;
#endif
else
levels = standaloneScenes;
//=====
//First, save the current scene!
//WARNING Running a build will save your current scene
//This is 'destructive' if you're not using version control or didnt want to save.
//=====
EditorApplication.SaveScene (EditorApplication.currentScene);
//Duplicate the scenes to work on them, then we can restore the originals later on
foreach (string scenePath in levels) {
string newPath = scenePath.Insert (scenePath.IndexOf (".unity"), "_temp");
//Rename the original scenes with a _temp suffix
AssetDatabase.MoveAsset (scenePath, newPath);
//Rename original scene file
AssetDatabase.CopyAsset (newPath, scenePath);
//Create duplicate file that uses the original scene file name
}
//Loop through each scene
foreach (string scenePath in levels) {
//Open the scene
EditorApplication.OpenScene (scenePath);
Debug.Log ("Processing scene: " + scenePath);
//Find all instances of PlatformSpecifics and apply the changes specified therein
PlatformSpecifics[] specifics = FindObjectsOfType (typeof(PlatformSpecifics)) as PlatformSpecifics[];
ApplyPlatformSpecifics (specifics, platform, stripMaterials);
//Save, then do it again!
EditorApplication.SaveScene (scenePath);
AssetDatabase.Refresh ();
}
//Set the Editor to return to the first scene in the build settings, now that we're done combing through the scenes
EditorApplication.OpenScene (levels[0]);
//Revert platform override to what was previously set
EditorPrefs.SetString (Platforms.editorPlatformOverrideKey, previousPlatformOverride);
}
示例5: ApplyLocalScale
public void ApplyLocalScale(Platform platform)
{
if(localScalePerPlatform != null) {
foreach(LocalScalePerPlatform pair in localScalePerPlatform) {
if (isCompatiblePlatform(platform, pair.platform)) {
transform.localScale = pair.localScale;
break;
}
}
}
if(Platforms.IsPlatformAspectBased(platform.ToString()) && localScalePerAspectRatio != null) {
foreach(LocalScalePerAspectRatio pair in localScalePerAspectRatio) {
if(AspectRatios.GetAspectRatio() == pair.aspectRatio) {
transform.localScale = pair.localScale;
break;
}
}
}
}
示例6: generateProfilerOutputName
private string generateProfilerOutputName(Platform platform, Version framework)
{
var activeRunGuid = Guid.NewGuid();
var dir = Path.GetTempPath();
var filename = string.Format("mm_output_{0}_{1}_v{2}_{4}_{3}.log", Process.GetCurrentProcess().Id, platform.ToString(), framework.ToString(), activeRunGuid.ToString(), Path.GetFileNameWithoutExtension(Path.GetTempFileName()));
return Path.Combine(dir, filename);
}
示例7: OnGUI
void OnGUI()
{
currentEditorPlatform = (EditorPlatform)EditorGUILayout.EnumPopup("Platform: ", (System.Enum)currentEditorPlatform);
currentPlatform = convertPlatform(currentEditorPlatform);
if(GUI.changed) {
EditorPrefs.SetString(Platforms.editorPlatformOverrideKey, currentPlatform.ToString());
}
// apply changes to scene
if (GUILayout.Button("Apply To Scene")) applyPlatformToScene();
}