本文整理汇总了C#中UnityEngine.Sprite类的典型用法代码示例。如果您正苦于以下问题:C# Sprite类的具体用法?C# Sprite怎么用?C# Sprite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sprite类属于UnityEngine命名空间,在下文中一共展示了Sprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Button
public Button(DisplayObject upState, string text ="", DisplayObject downState=null, TextFormat format=null)
{
//if (upState == null) throw new ErrorEvent("Texture cannot be null");
mParent = upState.parent;
mUpState = upState;
mDownState = downState != null ? downState : upState;
mBackground = upState;
mTextFormat = format;
mScaleWhenDown = 0.9f;
mAlphaWhenDisabled = 0.5f;
mEnabled = true;
mIsDown = false;
mUseHandCursor = true;
mTextBounds = new Rectangle(0, 0, upState.width, upState.height);
mContents = new Sprite();
mContents.addChild(mBackground);
addChild(mContents);
//addEventListener(TouchEvent.TOUCH, onTouch);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
if (text.Length > 0) this.text = text;
this.x = upState.x;
this.y = upState.y;
upState.x = upState.y = 0;
if(mParent != null)
(mParent as MovieClip).addChild(this);
}
示例2: DrawSprite
// Draw the specified Image.
public static void DrawSprite(Sprite sprite, Rect drawArea, Color color)
{
if (sprite == null)
return;
Texture2D tex = sprite.texture;
if (tex == null)
return;
Rect outer = sprite.rect;
Rect inner = outer;
inner.xMin += sprite.border.x;
inner.yMin += sprite.border.y;
inner.xMax -= sprite.border.z;
inner.yMax -= sprite.border.w;
Vector4 uv4 = UnityEngine.Sprites.DataUtility.GetOuterUV(sprite);
Rect uv = new Rect(uv4.x, uv4.y, uv4.z - uv4.x, uv4.w - uv4.y);
Vector4 padding = UnityEngine.Sprites.DataUtility.GetPadding(sprite);
padding.x /= outer.width;
padding.y /= outer.height;
padding.z /= outer.width;
padding.w /= outer.height;
DrawSprite(tex, drawArea, padding, outer, inner, uv, color, null);
}
示例3: BackgroundScript
/// <summary>
/// 주어진 정보를 이용하여 BackgroundScript 인스턴스를 초기화합니다.
/// </summary>
/// <param name="spriteToUse">사용할 Sprite 파일을 가리킵니다.</param>
/// <param name="isWrappingUI">이 스크립트가 현재 UI를 덮어서 적용되는 것인지 결정합니다.</param>
public BackgroundScript(Sprite spriteToUse, bool isWrappingUI)
{
base.ScriptCode = (int)ScriptTypeCode.BackgroundScript;
base.IsStepScript = false;
this.BackgroundSprite = spriteToUse;
this.IsWrappingUI = isWrappingUI;
}
示例4: BlueprintObject
public BlueprintObject(string name, Sprite sprite, float x_location, float y_location)
{
this.name = name;
this.sprite = sprite;
x = x_location;
y = y_location;
}
示例5: Create
public static pb_GUIStyle Create(
Color color,
Color? normalColor = null,
Color? highlightedColor = null,
Color? pressedColor = null,
Color? disabledColor = null,
Texture2D image = null,
Sprite sprite = null,
Font font = null,
Color? fontColor = null)
{
pb_GUIStyle style = ScriptableObject.CreateInstance<pb_GUIStyle>();
style.color = color;
style.image = image;
style.sprite = sprite;
style.font = font;
if(normalColor != null) style.normalColor = (Color) normalColor;
if(highlightedColor != null) style.highlightedColor = (Color) highlightedColor;
if(pressedColor != null) style.pressedColor = (Color) pressedColor;
if(disabledColor != null) style.disabledColor = (Color) disabledColor;
if(fontColor != null) style.fontColor = (Color) fontColor;
return style;
}
示例6: CreateTexture
private Texture2D CreateTexture(Sprite sprite)
{
if (!sprite)
{
return null;
}
Texture2D texture = null;
try
{
texture = SetupTexture(sprite);
}
catch
{
string path = AssetDatabase.GetAssetPath(sprite);
TextureImporter importer = (TextureImporter)AssetImporter.GetAtPath(path);
importer.isReadable = true;
AssetDatabase.ImportAsset(path);
try
{
texture = SetupTexture(sprite);
}
catch
{
Debug.LogError("Texture error!");
}
}
return texture;
}
示例7: CreateSpriteMesh
public static SpriteMesh CreateSpriteMesh(Sprite sprite)
{
SpriteMesh spriteMesh = SpriteMeshPostprocessor.GetSpriteMeshFromSprite(sprite);
SpriteMeshData spriteMeshData = null;
if(!spriteMesh && sprite)
{
string spritePath = AssetDatabase.GetAssetPath(sprite);
string directory = Path.GetDirectoryName(spritePath);
string assetPath = AssetDatabase.GenerateUniqueAssetPath(directory + Path.DirectorySeparatorChar + sprite.name + ".asset");
spriteMesh = ScriptableObject.CreateInstance<SpriteMesh>();
InitFromSprite(spriteMesh,sprite);
AssetDatabase.CreateAsset(spriteMesh,assetPath);
spriteMeshData = ScriptableObject.CreateInstance<SpriteMeshData>();
spriteMeshData.name = spriteMesh.name + "_Data";
spriteMeshData.hideFlags = HideFlags.HideInHierarchy;
InitFromSprite(spriteMeshData,sprite);
AssetDatabase.AddObjectToAsset(spriteMeshData,assetPath);
UpdateAssets(spriteMesh,spriteMeshData);
AssetDatabase.SaveAssets();
AssetDatabase.ImportAsset(assetPath);
Selection.activeObject = spriteMesh;
}
return spriteMesh;
}
示例8: Load
/// <summary>
/// エディタ上に保存してあるデータをロード
/// </summary>
void Load()
{
gameScreenWidth = UtageEditorPrefs.LoadInt(UtageEditorPrefs.Key.GameScreenWidth, 800);
gameScreenHeight = UtageEditorPrefs.LoadInt(UtageEditorPrefs.Key.GameScreenHegiht, 600);
font = UtageEditorPrefs.LoadAsset<FontData>(UtageEditorPrefs.Key.CreateAdvEngineWindowFont,
"Assets/Utage/Examples/ScriptableObject/Example FontData.asset");
clickSe = UtageEditorPrefs.LoadAsset<AudioClip>(UtageEditorPrefs.Key.CreateAdvEngineWindowClickSe,
"Assets/Utage/Examples/Audio/mouse_click.wav");
transitionFadeBg = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowTransitionFadeBg,
"Assets/Utage/Examples/Textures/UI/transitionFadeBg.png");
msgWindowSprite = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowMsgWindowSprite,
"Assets/Utage/Examples/Textures/UI/MessageWindow.png");
isEnableCloseButton = UtageEditorPrefs.LoadBool(UtageEditorPrefs.Key.CreateAdvEngineWindowIsEnableCloseButton, true);
closeButtonSprite = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowCloseButtonSprite,
"Assets/Utage/Examples/Textures/UI/CloseIcon.png");
selectionItemPrefab = UtageEditorPrefs.LoadPrefab<AdvUiSelection>(UtageEditorPrefs.Key.CreateAdvEngineWindowSelectionItemPrefab,
"Assets/Utage/Examples/Prefabs/SelectionItem.prefab");
isEnableBackLog = UtageEditorPrefs.LoadBool(UtageEditorPrefs.Key.CreateAdvEngineWindowIsEnableCloseButton,true);
backLogButtonSprite = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowBackLogButtonSprite,
"Assets/Utage/Examples/Textures/UI/SystemButtonSS.png");
backLogFilterSprite = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowBackLogFilterSprite,
"Assets/Utage/Examples/Textures/UI/filterBg.png");
backLogScrollUpArrow = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowBackLogScrollUpArrow,
"Assets/Utage/Examples/Textures/UI/AllowUp.png");
backLogItemPrefab = UtageEditorPrefs.LoadPrefab<AdvUiBacklog>(UtageEditorPrefs.Key.CreateAdvEngineWindowBackLogItemPrefab,
"Assets/Utage/Examples/Prefabs/BacklogItem.prefab");
backLogCloseButtonSprite = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowBackLogCloseButtonSprite,
"Assets/Utage/Examples/Textures/UI/SystemButtonSS.png");
}
示例9: Awake
// Use this for initialization
void Awake()
{
board = new Logic.Board();
board.CreateAnimals();
boardSprite = GetComponent<SpriteRenderer>().sprite;
}
示例10: Reset
public override void Reset() {
base.Reset();
this.tempSprite = null;
}
示例11: Validate
public override void Validate(Object item) {
base.Validate(item);
if (item == null) {
if (this.tempSprite != null) {
item = this.tempSprite;
}
if (item == null) return;
}
this.tempSprite = item as Sprite;
if (this.tempSprite != null) {
var imp = UnityEditor.TextureImporter.GetAtPath(this.assetPath) as UnityEditor.TextureImporter;
this.multiObjects = false;
if (imp.spriteImportMode == UnityEditor.SpriteImportMode.Multiple) {
var allObjects = Resources.LoadAll(this.resourcesPath);
this.multiObjects = true;
this.objectIndex = System.Array.IndexOf(allObjects, item);
}
}
}
示例12: AddWeapon
public void AddWeapon(string name, int atk, Sprite sprite)
{
Name = name;
Atk = atk;
SpriteWeapon = sprite;
_listWeapons.Add (this);
}
示例13: AssignValues
public Text txtName; //Used to Store and Display Name from the server
#endregion Fields
#region Methods
public void AssignValues(string fId, string picUrl, string txtName, Sprite imgPic)
{
this.fId = fId;
this.picUrl = picUrl;
this.txtName.text = txtName;
this.imgPic.sprite = imgPic;
}
示例14: GenerateBall
public void GenerateBall(int number, Vector3 position, Sprite mySprite){
text = transform.GetChild(0).GetComponent<Text>();
GetComponent<Image>().sprite = mySprite;
GetComponent<RectTransform>().anchoredPosition = position;
ballNumber = number;
text.text = number.ToString();
}
示例15: addSprite
public void addSprite(string path, Sprite sprite)
{
SerialObject obj = new SerialObject();
obj.m_sprite = sprite;
obj.m_path = path;
m_objList.Add(obj);
}