當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.Sprite類代碼示例

本文整理匯總了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);
        }
開發者ID:crl,項目名稱:UniStarling,代碼行數:33,代碼來源:Button.cs

示例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);
        }
開發者ID:gdzzzyyy,項目名稱:UGUIlok,代碼行數:27,代碼來源:SpriteDrawUtility.cs

示例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;
 }
開發者ID:watermelonbar,項目名稱:ProjectAILibrary,代碼行數:12,代碼來源:BackgroundScript.cs

示例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;
 }
開發者ID:jee7,項目名稱:BuildingGenerator2D,代碼行數:7,代碼來源:BlueprintObject.cs

示例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;
		}
開發者ID:procore3d,項目名稱:giles,代碼行數:26,代碼來源:pb_GUIStyle.cs

示例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;
        }
開發者ID:LawsonLamb,項目名稱:out_foxed,代碼行數:30,代碼來源:TileData.cs

示例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;
		}
開發者ID:Kundara,項目名稱:project1,代碼行數:31,代碼來源:SpriteMeshUtils.cs

示例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");
		}
開發者ID:OsamaRazaAnsari,項目名稱:2DDressUpGame,代碼行數:36,代碼來源:CreateAdvEngineWindow.cs

示例9: Awake

        // Use this for initialization
        void Awake()
        {
            board = new Logic.Board();
            board.CreateAnimals();

            boardSprite = GetComponent<SpriteRenderer>().sprite;
        }
開發者ID:Pavelko007,項目名稱:AnimalChess,代碼行數:8,代碼來源:Board.cs

示例10: Reset

		public override void Reset() {
			
			base.Reset();
			
			this.tempSprite = null;
			
		}
開發者ID:Cyberbanan,項目名稱:Unity3d.UI.Windows,代碼行數:7,代碼來源:SpriteResourceItem.cs

示例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);

				}

			}

		}
開發者ID:Cyberbanan,項目名稱:Unity3d.UI.Windows,代碼行數:33,代碼來源:SpriteResourceItem.cs

示例12: AddWeapon

 public void AddWeapon(string name, int atk, Sprite sprite)
 {
     Name = name;
     Atk = atk;
     SpriteWeapon = sprite;
     _listWeapons.Add (this);
 }
開發者ID:Eleart,項目名稱:SimpleQuest,代碼行數:7,代碼來源:Weapon.cs

示例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;
        }
開發者ID:amisiak7,項目名稱:jewels2,代碼行數:13,代碼來源:ListItemGift.cs

示例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();                            
 }
開發者ID:loloop,項目名稱:totem-master,代碼行數:7,代碼來源:BallGameButton.cs

示例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);
 }
開發者ID:zhutaorun,項目名稱:unitygame,代碼行數:7,代碼來源:SOSpriteList.cs


注:本文中的UnityEngine.Sprite類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。