Difference between revisions of "DeviceOrientationMoveOnChange"

From Headbone Creative
Jump to: navigation, search
(Initial page, includes API information and categories)
 
(Updating API info)
Line 1: Line 1:
This script will reposition the object it's attached to when the aspect ratio changes.
+
This script will reposition the object it's attached to when the size of the screen changes.  
 
+
It has a custom editor with buttons that set the aspect ratio for iOS devices. It also maintains a list of settings for different aspect ratios.
+
  
 
== Public Variables ==
 
== Public Variables ==
 +
=== positions : List<PositionSettings> ===
 +
This class maintains a list of settings that will be used to reposition the object when the screen size changes. These settings are stored in a class with the following definition:
 +
  public class PositionSettings {
 +
      public int width = 0;
 +
      public int height = 0;
 +
      public Vector3 position = Vector3.zero;
 +
  };
 +
=== useLocalPosition : bool ===
 +
This tells the class whether or not to use the local position or the world position. This shouldn't be changed once positions are saved.
 +
 +
== Editor Interface ==
 +
This class comes with a custom editor interface that allows the designer to easily save and restore the position of the object for various screen sizes. Many common device screen sizes are provided in a drop-down menu. The buttons will allow you to save the position for the currently selected device and for all supported devices, as well as restore the position for the currently selected device.
 +
 +
To save a position for a specific device, select the device from the drop down and then click "Save Current Position". Custom screen sizes can also be saved by selecting Custom from the drop-down menu.
  
public class PositionSettings {
+
To save the current position for all supported devices, click on "Save All Positions".  
public float aspectRatio = 0.0f;
+
public Vector3 position = Vector3.zero;
+
};
+
+
/// <summary>
+
/// The positions.
+
/// </summary>
+
public List<PositionSettings> positions = new List<PositionSettings>();
+
+
/// <summary>
+
/// The use local position flag
+
/// </summary>
+
public bool useLocalPosition = true;
+
  
 +
To restore the position for a specific device, select the device from the drop-down menu and click "Restore Position". 
  
 
[[Category:API]]
 
[[Category:API]]
 
[[Category:Mobile]]
 
[[Category:Mobile]]
 
[[Category:Premium Scripts]]
 
[[Category:Premium Scripts]]

Revision as of 03:45, 18 April 2013

This script will reposition the object it's attached to when the size of the screen changes.

Contents

Public Variables

positions : List<PositionSettings>

This class maintains a list of settings that will be used to reposition the object when the screen size changes. These settings are stored in a class with the following definition:

  public class PositionSettings {
     public int width = 0;
     public int height = 0;
     public Vector3 position = Vector3.zero;
  };

useLocalPosition : bool

This tells the class whether or not to use the local position or the world position. This shouldn't be changed once positions are saved.

Editor Interface

This class comes with a custom editor interface that allows the designer to easily save and restore the position of the object for various screen sizes. Many common device screen sizes are provided in a drop-down menu. The buttons will allow you to save the position for the currently selected device and for all supported devices, as well as restore the position for the currently selected device.

To save a position for a specific device, select the device from the drop down and then click "Save Current Position". Custom screen sizes can also be saved by selecting Custom from the drop-down menu.

To save the current position for all supported devices, click on "Save All Positions".

To restore the position for a specific device, select the device from the drop-down menu and click "Restore Position".

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox