public Terrain(Device device, String texture, int pitch, Renderer renderer) { HeightMap = new System.Drawing.Bitmap(@"Data/Textures/"+texture); WaterShader = new WaterShader(device); TerrainShader = new TerrainShader(device); _width = HeightMap.Width-1; _height = HeightMap.Height-1; _pitch = pitch; _terrainTextures = new ShaderResourceView[4]; _terrainTextures[0] = new Texture(device, "Sand.png").TextureResource; _terrainTextures[1] = new Texture(device, "Grass.png").TextureResource; _terrainTextures[2] = new Texture(device, "Ground.png").TextureResource; _terrainTextures[3] = new Texture(device, "Rock.png").TextureResource; _reflectionClippingPlane = new Vector4(0.0f, 1.0f, 0.0f, 0.0f); _refractionClippingPlane = new Vector4(0.0f, -1.0f, 0.0f, 0.0f); _noClippingPlane = new Vector4(0.0f, 1.0f, 0.0f, 10000); _reflectionTexture = new RenderTexture(device, renderer.ScreenSize); _refractionTexture = new RenderTexture(device, renderer.ScreenSize); _renderer = renderer; _bitmap = new Bitmap(device,_refractionTexture.ShaderResourceView,renderer.ScreenSize, new Vector2I(100, 100), 0); _bitmap.Position = new Vector2I(renderer.ScreenSize.X - 100, 0); _bitmap2 = new Bitmap(device, _reflectionTexture.ShaderResourceView, renderer.ScreenSize, new Vector2I(100, 100), 0); _bitmap2.Position = new Vector2I(renderer.ScreenSize.X - 100, 120); _bumpMap = _renderer.TextureManager.Create("OceanWater.png"); _skydome = new ObjModel(device, "skydome.obj", renderer.TextureManager.Create("Sky.png")); BuildBuffers(device); WaveTranslation = new Vector2(0,0); }
public ControlButton(GUITexture _gui, Texture _textureOn, Texture _textureOff) { // isPlayer = Application.platform == RuntimePlatform.OSXPlayer; gui = _gui; textureOn = _textureOn; textureOff = _textureOff; }
public void init() { time_texture = Resources.Load("textures/time_gui") as Texture; rstats_texture = Resources.Load("textures/rstats_gui") as Texture; float w = time_texture.width; time_gui_rect = new Rect(0, 0, w, time_texture.height); rstats_gui_rect = new Rect(Screen.width - w, 0, w, rstats_texture.height); int s_w = Screen.width, s_h = Screen.height; debug_rect = new Rect(0, time_texture.height, s_w, (s_h * 2) / 100); debug_style.alignment = TextAnchor.UpperLeft; debug_style.fontSize = (s_h * 2) / 80; debug_style.normal.textColor = new Color(1, 1, 1, 1); Font gui_font = Resources.Load("fonts/gui_font") as Font; timer_rect = new Rect((time_gui_rect.width / 2.0f) - 125, (time_gui_rect.height / 2.0f) - 40, timer_rect.width, timer_rect.height); timer_style.alignment = TextAnchor.UpperLeft; timer_style.fontSize = (int)(time_texture.height / 2.0f); timer_style.normal.textColor = new Color(1, 1, 1, 1); timer_style.font = gui_font; rstats_rect = new Rect(rstats_gui_rect.x + ((rstats_gui_rect.width / 2.0f) - 50), (rstats_gui_rect.height / 2.0f) - 40, rstats_rect.width, rstats_rect.height); rstats_style.alignment = TextAnchor.UpperLeft; rstats_style.fontSize = (rstats_font_size = (int)(rstats_texture.height / 2.0f)); rstats_style.normal.textColor = new Color(1, 1, 1, 1); rstats_style.font = gui_font; }
public void Create( tk2dSpriteCollectionSize spriteCollectionSize, Texture texture, tk2dBaseSprite.Anchor anchor ) { DestroyInternal(); if (texture != null) { // Copy values this.spriteCollectionSize.CopyFrom( spriteCollectionSize ); this.texture = texture; this.anchor = anchor; GameObject go = new GameObject("tk2dSpriteFromTexture - " + texture.name); go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; go.hideFlags = HideFlags.DontSave; Vector2 anchorPos = tk2dSpriteGeomGen.GetAnchorOffset( anchor, texture.width, texture.height ); spriteCollection = tk2dRuntime.SpriteCollectionGenerator.CreateFromTexture( go, texture, spriteCollectionSize, new Vector2(texture.width, texture.height), new string[] { "unnamed" } , new Rect[] { new Rect(0, 0, texture.width, texture.height) }, null, new Vector2[] { anchorPos }, new bool[] { false } ); string objName = "SpriteFromTexture " + texture.name; spriteCollection.spriteCollectionName = objName; spriteCollection.spriteDefinitions[0].material.name = objName; spriteCollection.spriteDefinitions[0].material.hideFlags = HideFlags.DontSave | HideFlags.HideInInspector; Sprite.SetSprite( spriteCollection, 0 ); } }
public void Update(float x, float y, float width, float height, Texture tex, float alpha) { Position = new Vector2(x, y); Size = new Vector2(width, height); Tex = tex; Alpha = alpha; }
public ParticleEffect AddEffect(ParticleEffectType type, Func<ParticleEffect, Location> start, Func<ParticleEffect, Location> end, Func<ParticleEffect, float> fdata, float ttl, Location color, Location color2, bool fades, Texture texture, float salpha = 1) { ParticleEffect pe = new ParticleEffect(TheClient) { Type = type, Start = start, End = end, FData = fdata, TTL = ttl, O_TTL = ttl, Color = color, Color2 = color2, Alpha = salpha, Fades = fades, texture = texture }; ActiveEffects.Add(pe); return pe; }
public void TextureChange(Texture a,Vector3 _scale,int _kind) { GetComponent<Animation>().Stop(); GetComponent<Animation>().Play("dt1"); delay_finish =0; downaccel = 0; if (_kind ==2) { mytransform.Find("p1").GetComponent<Renderer>().material.SetTexture("_MainTex", a); mytransform.Find("p2").GetComponent<Renderer>().material.SetTexture("_MainTex", a); if (_scale.x>1) { mytransform.localScale = _scale *1.2f; headbone.localScale = Vector3.one*0.7f; } else { mytransform.localScale = Vector3.one * 1.2f; headbone.localScale = Vector3.one; } } else GetComponent<Animation>()["dt1"].speed = 0.55f; //falldowndir = attackdir; }
public void DrawItem(OSDTexture item) { try { lock (_OSDLock) { if (item.texture != null && item.width > 0 && item.height > 0) { // todo: support 2 planes if (_OSDTexture == null) { _OSDTexture = new Texture(item.texture); } } else { _OSDTexture = null; } } } catch (Exception ex) { Log.Error(ex); } }
void Start(){ // Initialise voting prefab here int _numOfOptions = 4; _texture = new Texture[_numOfOptions]; _texture[0] = Resources.Load("Textures/Drum/0") as Texture; _texture[1] = Resources.Load("Textures/Drum/1") as Texture; _texture[2] = Resources.Load("Textures/Drum/2") as Texture; _texture[3] = Resources.Load("Textures/Drum/3") as Texture; _overTexture = new Texture[_numOfOptions]; _overTexture[0] = Resources.Load("Textures/Drum/0c") as Texture; _overTexture[1] = Resources.Load("Textures/Drum/1c") as Texture; _overTexture[2] = Resources.Load("Textures/Drum/2c") as Texture; _overTexture[3] = Resources.Load("Textures/Drum/3c") as Texture; _transform = new Transform[_numOfOptions]; _transform[0] = transform.FindChild("Zero"); _transform[1] = transform.FindChild("One"); _transform[2] = transform.FindChild("Two"); _transform[3] = transform.FindChild("Three"); _renderer = new Renderer[_numOfOptions]; for(int i=0; i<_numOfOptions; i++){ _renderer[i] = _transform[i].GetComponent<Renderer>(); } }
public Video(Form _form1_reference) { form1_reference = _form1_reference; critical_failure = false; Load_Window_Size(); if (!initialize_directx()) { MessageBox.Show("problem with directx initialization"); fatal_error = true; return; } try { texture = new Texture(device, 256, 256, 1, Usage.Dynamic, Format.A8R8G8B8, Pool.Default); data_copy = new int[256 * 256]; } catch (Direct3D9Exception e) { MessageBox.Show("Gameboy Revolution failed to create rendering surface. \nPlease report this error. \n\nDirectX Error:\n" + e.ToString(), "Error!", MessageBoxButtons.OK); fatal_error = true; return; } setup_screen(); setup_colors(); }
// Use this for initialization void Start () { _animator = GetComponent<Animator>(); _charCtrl = GetComponent<CharacterController>(); m_AudioSource = GetComponent<AudioSource>(); currTexture = myBody.GetComponent<SkinnedMeshRenderer> ().material.mainTexture; }
void Start() { playerLabel.text = "Player Diconnected"; defaulttexture = avatar.GetComponent<Renderer>().material.mainTexture; //listen for GooglePlayConnection events GooglePlayConnection.instance.addEventListener (GooglePlayConnection.PLAYER_CONNECTED, OnPlayerConnected); GooglePlayConnection.instance.addEventListener (GooglePlayConnection.PLAYER_DISCONNECTED, OnPlayerDisconnected); GooglePlayConnection.instance.addEventListener(GooglePlayConnection.CONNECTION_RESULT_RECEIVED, OnConnectionResult); //listen for GooglePlayManager events GooglePlayManager.instance.addEventListener (GooglePlayManager.ACHIEVEMENT_UPDATED, OnAchivmentUpdated); GooglePlayManager.instance.addEventListener (GooglePlayManager.SCORE_SUBMITED, OnScoreSubmited); GooglePlayManager.instance.addEventListener (GooglePlayManager.SEND_GIFT_RESULT_RECEIVED, OnGiftResult); GooglePlayManager.instance.addEventListener (GooglePlayManager.PENDING_GAME_REQUESTS_DETECTED, OnPendingGiftsDetected); GooglePlayManager.instance.addEventListener (GooglePlayManager.GAME_REQUESTS_ACCEPTED, OnGameRequestAccepted); GooglePlayManager.instance.addEventListener (GooglePlayManager.AVALIABLE_DEVICE_ACCOUNT_LOADED, OnAccsLoaded); GooglePlayManager.instance.addEventListener (GooglePlayManager.OAUTH_TOCKEN_LOADED, OnToeknLoaded); if(GooglePlayConnection.state == GPConnectionState.STATE_CONNECTED) { //checking if player already connected OnPlayerConnected (); } }
// Use this for initialization void Start() { currTime = 0; isBubbleVisible = false; defaultTimeToDisplaySpeechBubble = 3; speechBubble = (Texture)Resources.Load("speech_bubble"); }
static SpriteMetaData[] CreateSpriteMetaDataArray( Texture texture, int horizontalCount, int verticalCount) { float spriteWidth = texture.width / horizontalCount; float spriteHeight = texture.height / verticalCount; return Enumerable .Range(0, horizontalCount * verticalCount) .Select(index => { int x = index % horizontalCount; int y = index / horizontalCount; return new SpriteMetaData { name = string.Format("{0}_{1}", texture.name, index), rect = new Rect( x: spriteWidth * x, y: texture.height - spriteHeight * (y + 1), width: spriteWidth, height: spriteHeight) }; }) .ToArray(); }
void Start() { playerLabel.text = "Player Disconnected"; defaulttexture = avatar.GetComponent<Renderer>().material.mainTexture; //listen for GooglePlayConnection events GooglePlayInvitationManager.ActionInvitationReceived += OnInvite; GooglePlayInvitationManager.ActionInvitationAccepted += ActionInvitationAccepted; GooglePlayRTM.ActionRoomCreated += OnRoomCreated; GooglePlayConnection.ActionPlayerConnected += OnPlayerConnected; GooglePlayConnection.ActionPlayerDisconnected += OnPlayerDisconnected; GooglePlayConnection.ActionConnectionResultReceived += OnConnectionResult; if(GooglePlayConnection.State == GPConnectionState.STATE_CONNECTED) { //checking if player already connected OnPlayerConnected (); } //networking event GooglePlayRTM.ActionDataRecieved += OnGCDataReceived; }
static public void SetOverride( Texture front = null, Texture back = null, Texture left = null, Texture right = null, Texture top = null, Texture bottom = null ) { var compositor = OpenVR.Compositor; if (compositor != null) { var handles = new Texture[] { front, back, left, right, top, bottom }; var textures = new Texture_t[6]; for (int i = 0; i < 6; i++) { textures[i].handle = (handles[i] != null) ? handles[i].GetNativeTexturePtr() : System.IntPtr.Zero; textures[i].eType = SteamVR.instance.graphicsAPI; textures[i].eColorSpace = EColorSpace.Auto; } var error = compositor.SetSkyboxOverride(textures); if (error != EVRCompositorError.None) { Debug.LogError("Failed to set skybox override with error: " + error); if (error == EVRCompositorError.TextureIsOnWrongDevice) Debug.Log("Set your graphics driver to use the same video card as the headset is plugged into for Unity."); else if (error == EVRCompositorError.TextureUsesUnsupportedFormat) Debug.Log("Ensure skybox textures are not compressed and have no mipmaps."); } } }
public MenuTemplate(string name) { menuName = name; itemTemplates = new ArrayList (); mainBackground = Resources.Load ("Textures/MainBackground") as Texture; setStyles (); }
public override void Load(XmlNode xnode) { type = LocalType.Get(xnode.Name); texture = new Texture(); name = MyXml.GetString(xnode, "name"); variations = MyXml.GetInt(xnode, "variations", 1); maxHP = MyXml.GetInt(xnode, "hp"); damage = MyXml.GetInt(xnode, "damage"); attack = MyXml.GetInt(xnode, "attack"); defence = MyXml.GetInt(xnode, "defence"); armor = MyXml.GetInt(xnode, "armor"); movementTime = MyXml.GetFloat(xnode, "movementTime"); attackTime = MyXml.GetFloat(xnode, "attackTime"); isWalkable = MyXml.GetBool(xnode, "walkable"); isFlat = MyXml.GetBool(xnode, "flat"); if (xnode.Name == "Thing") isWalkable = true; string s = MyXml.GetString(xnode, "type"); if (s != "") creatureType = CreatureType.Get(s); s = MyXml.GetString(xnode, "corpse"); if (creatureType != null && (creatureType.name == "Animal" || creatureType.name == "Sentient")) s = "Blood"; if (s != "") corpse = Get(s); s = MyXml.GetString(xnode, "onDeath"); if (creatureType != null && creatureType.name == "Animal") s = "Large Chunk of Meat"; if (s != "") onDeath = ItemShape.Get(s); for (xnode = xnode.FirstChild; xnode != null; xnode = xnode.NextSibling) abilities.Add(BigBase.Instance.abilities.Get(MyXml.GetString(xnode, "name"))); }
static void Init() { EditorWindow.GetWindow(typeof(IM_Manager)); headTexture = Resources.Load<Texture>("EditorWindowTextures/headTexture"); skypeTexture = Resources.Load<Texture>("EditorWindowTextures/skype-icon"); emailTexture = Resources.Load<Texture>("EditorWindowTextures/email-icon"); folderIcon = Resources.Load<Texture>("EditorWindowTextures/folder-icon"); Object itemDatabase = Resources.Load("ItemDatabase"); if (itemDatabase == null) inventoryItemList = CreateItemDatabase.createItemDatabase(); else inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); Object attributeDatabase = Resources.Load("AttributeDatabase"); if (attributeDatabase == null) itemAttributeList = CreateAttributeDatabase.createItemAttributeDatabase(); else itemAttributeList = (ItemAttributeList)Resources.Load("AttributeDatabase"); Object inputManager = Resources.Load("InputManager"); if (inputManager == null) inputManagerDatabase = CreateInputManager.createInputManager(); else inputManagerDatabase = (InputManager)Resources.Load("InputManager"); }
public void SetTextureWinPlayer(CPlayer.EIdPlayer eId) { switch(eId) { case CPlayer.EIdPlayer.e_Player1: { m_TextureWinPlayer = m_Texture_Player1; break; } case CPlayer.EIdPlayer.e_Player2: { m_TextureWinPlayer = m_Texture_Player2; break; } case CPlayer.EIdPlayer.e_Player3: { m_TextureWinPlayer = m_Texture_Player3; break; } case CPlayer.EIdPlayer.e_Player4: { m_TextureWinPlayer = m_Texture_Player4; break; } } }
protected override async Task LoadContent() { await base.LoadContent(); var view = Matrix.LookAtRH(new Vector3(2,2,2), new Vector3(0, 0, 0), Vector3.UnitY); var projection = Matrix.PerspectiveFovRH((float)Math.PI / 4.0f, (float)GraphicsDevice.BackBuffer.ViewWidth / GraphicsDevice.BackBuffer.ViewHeight, 0.1f, 100.0f); worldViewProjection = Matrix.Multiply(view, projection); geometry = GeometricPrimitive.Cube.New(GraphicsDevice); simpleEffect = new Effect(GraphicsDevice, SpriteEffect.Bytecode); parameterCollection = new ParameterCollection(); parameterCollectionGroup = new EffectParameterCollectionGroup(GraphicsDevice, simpleEffect, new[] { parameterCollection }); parameterCollection.Set(TexturingKeys.Texture0, UVTexture); // TODO DisposeBy is not working with device reset offlineTarget0 = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget).DisposeBy(this); offlineTarget1 = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget).DisposeBy(this); offlineTarget2 = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget).DisposeBy(this); depthBuffer = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.D16_UNorm, TextureFlags.DepthStencil).DisposeBy(this); width = GraphicsDevice.BackBuffer.ViewWidth; height = GraphicsDevice.BackBuffer.ViewHeight; }
public static bool InitializeGraphics(Control handle) { try { presentParams.Windowed = true; presentParams.SwapEffect = SwapEffect.Discard; presentParams.EnableAutoDepthStencil = true; presentParams.AutoDepthStencilFormat = DepthFormat.D16; device = new Device(0, DeviceType.Hardware, handle, CreateFlags.SoftwareVertexProcessing, presentParams); CamDistance = 10; Mat = new Material(); Mat.Diffuse = Color.White; Mat.Specular = Color.LightGray; Mat.SpecularSharpness = 15.0F; device.Material = Mat; string loc = Path.GetDirectoryName(Application.ExecutablePath); DefaultTex = TextureLoader.FromFile(device, loc + "\\exec\\Default.bmp"); CreateCoordLines(); init = true; return true; } catch (DirectXException) { return false; } }
public override bool OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT: { base.OnMessage(message); Update(); return true; } case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT: { if (m_pTexture != null) { m_pTexture.Dispose(); } m_pTexture = null; base.OnMessage(message); // Fix for Mantis issue: 0001709: Background not correct after viewing pictures properties twice Restore(); return true; } } return base.OnMessage(message); }
/// <summary> /// Creates a fake <see cref="Texture"/> that will have the given serialized data version. /// </summary> /// <param name="image">The image.</param> /// <returns></returns> public static Texture ToSerializableVersion(this Image image) { var texture = new Texture(); texture.SetSerializationData(image); return texture; }
public TexturedExtensibleRectangle(IContext context, Vector2I size, Texture texture, int fixedBorderRadius) { DeviceContext = context.DirectX.DeviceContext; _shader = context.Shaders.Get<TextureShader>(); _texture = texture; _fixedBorderRadius = fixedBorderRadius; const int vertexCount = 16; _vertices = new VertexDefinition.PositionTexture[vertexCount]; VertexBuffer = Buffer.Create(context.DirectX.Device, _vertices, new BufferDescription { Usage = ResourceUsage.Dynamic, SizeInBytes = Utilities.SizeOf<VertexDefinition.PositionTexture>() * vertexCount, BindFlags = BindFlags.VertexBuffer, CpuAccessFlags = CpuAccessFlags.Write, OptionFlags = ResourceOptionFlags.None, StructureByteStride = 0 }); IndexCount = 54; uint[] indices = new uint[IndexCount]; for(uint i=0; i< 3; i++) for (uint j = 0; j < 3; j++) { indices[(i * 3 + j) * 6] = (i + 1) * 4 + j + 1; indices[(i * 3 + j) * 6 + 1] = i * 4 + j + 1; indices[(i * 3 + j) * 6 + 2] = i * 4 + j; indices[(i * 3 + j) * 6 + 3] = (i + 1) * 4 + j; indices[(i * 3 + j) * 6 + 4] = (i + 1) * 4 + j + 1; indices[(i * 3 + j) * 6 + 5] = i * 4 + j; } IndexBuffer = Buffer.Create(context.DirectX.Device, BindFlags.IndexBuffer, indices); Size = size; }
// Update is called once per frame void Update() { int x = (int) Input.mousePosition.x; int y = (int) Input.mousePosition.y; bool overCredits = (x > (creditsCoords[0] * Screen.width) && x < (creditsCoords[1] * Screen.width) && y > (creditsCoords[2] * Screen.height) && y < (creditsCoords[3] * Screen.height)); Debug.Log("Position! " + Input.mousePosition.x + ", " + Input.mousePosition.y); if(overCredits){ buttonTexture = buttonTexture2; } else buttonTexture = backTexture; if(Input.GetButtonDown("Fire1")){ //Left click //Credits Screen if(overCredits){ Application.LoadLevel("CharacterSelection"); } } else{ } }
public void Update(Vector2 pos, Vector2 size, Texture tex, float alpha) { Position = pos; Size = size; Tex = tex; Alpha = alpha; }
public override IsoDecoration[] textureList(Texture match) { if (!lists.ContainsKey (match)) regenerate (match); return lists [match].ToArray (); }
public Engine_Picture(string fileName, Color colorKey) { ImageInformation imageInformation = TextureLoader.ImageInformationFromFile(Engine_Game.PicturesPath + fileName); m_Width = imageInformation.Width; m_Height = imageInformation.Height; m_Texture = TextureLoader.FromFile(Engine_Game.Device, Engine_Game.PicturesPath + fileName, 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, colorKey.ToArgb()); }
protected override void CreateTexture() { if (ControlTexture != null && !ControlTexture.Disposed && Size != TextureSize) ControlTexture.Dispose(); if (ControlTexture == null || ControlTexture.Disposed) { DXManager.ControlList.Add(this); ControlTexture = new Texture(DXManager.Device, Size.Width, Size.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); ControlTexture.Disposing += ControlTexture_Disposing; TextureSize = Size; } Surface oldSurface = DXManager.CurrentSurface; Surface surface = ControlTexture.GetSurfaceLevel(0); DXManager.SetSurface(surface); DXManager.Device.Clear(ClearFlags.Target, BackColour, 0, 0); BeforeDrawControl(); DrawChildControls(); AfterDrawControl(); DXManager.Sprite.Flush(); DXManager.SetSurface(oldSurface); TextureValid = true; surface.Dispose(); }
protected override void OnDestroy() { currentMaterial = null; currentTexture = null; }
public static Texture ToTexture(this Bitmap bitmap) { return(Texture.FromMemory( Drawing.Direct3DDevice, (byte[])new ImageConverter().ConvertTo(bitmap, typeof(byte[])), bitmap.Width, bitmap.Height, 0, Usage.None, Format.A1, Pool.Managed, Filter.Default, Filter.Default, 0)); }
void Start() { crosshair = Resources.Load("crosshair") as Texture; timeSinceStart = Time.time; }
/// Copy the contents of one render texture into another. Assumes textures are the same size. public static void CopyRenderTexture(Texture source, RenderTexture target) { Graphics.Blit(source, target); }
public void DrawWidget(Rect bounds) { GUI.color = Color.white; GUI.DrawTexture(bounds, this.backgroundColor); GUI.color = this.borderColor; Widgets.DrawBox(bounds, 1); Rect position = bounds.ContractedBy(1f); try { GUI.BeginGroup(position); Rect outRect = new Rect(0f, 0f, position.width, position.height); Rect viewRect = new Rect(outRect.x, outRect.y, outRect.width - 16f, this.scrollableContentHeight); try { Widgets.BeginScrollView(outRect, ref this.scrollableContentViewPosition, viewRect); Vector2 cursor = new Vector2(0f, 0f); for (int i = 0; i < this.items.Count; i++) { bool flag = this.selectedIndices.Contains(i); T item = this.items[i]; float height = this.itemDrawer.GetHeight(i, item, cursor, position.width, flag, false); Rect rect = new Rect(cursor.x, cursor.y, position.width, height); Texture image = null; if (flag) { image = this.selectedTexture; } else if (this.rowTextures.Count > 0) { image = this.rowTextures[i % this.rowTextures.Count]; } if (this.backgroundColor != null) { GUI.color = Color.white; GUI.DrawTexture(rect, image); } cursor = this.itemDrawer.Draw(i, item, cursor, position.width, flag, false); if (Widgets.InvisibleButton(rect)) { if (this.SupportsMultiSelect) { if (Event.current.control) { this.ToggleSelection(i); } else if (Event.current.shift) { this.SelectThrough(i); } else { this.Select(i); } } else { this.Select(i); } } } if (Event.current.type == EventType.Layout) { this.scrollableContentHeight = cursor.y; } } finally { Widgets.EndScrollView(); } } catch (Exception ex) { throw ex; } finally { GUI.EndGroup(); } GUI.color = Color.white; }
private static void DrawTexturedRect(Box2D rect, Texture tex, Box2D texCoords) { tex.Activate(); rect.DrawTexturedRect(texCoords); tex.Deactivate(); }
private MyVisual() { texBackground = TextureLoader.FromBitmap(Resourcen.mountains); //background clear color GL.ClearColor(Color.Black); }
static public void SetMainTexture(this Material item, Texture texture) { item.SetTexture("_MainTex", texture); }
private void Update() { inventoryObject = GetComponentInParent <InventoryObject>(); activationCharacter = activationCharacters[activationInt]; if (!allSlots.Contains(this)) { allSlots.Add(this); } slotRawIconImage.rectTransform.sizeDelta = rectTransform.sizeDelta - new Vector2(5, 5); backgroundRawImage.rectTransform.sizeDelta = rectTransform.sizeDelta; stackText.rectTransform.sizeDelta = rectTransform.sizeDelta; slotText.rectTransform.sizeDelta = rectTransform.sizeDelta; activationCharacterText.rectTransform.sizeDelta = rectTransform.sizeDelta; //Find out when an element is equipped if (Application.isPlaying) { if (inventoryElement != null) { if (inventoryElement.id > -1) { if (cachedItem == null) { cachedItem = inventoryElement; if (acceptedTypes.Exists(x => x.ID == inventoryElement.type.ID || x.isAncestorOf(inventoryElement.type))) { foreach (ElementAction itemAction in inventoryElement.actions) { if (itemAction.activateOnEquip) { inventoryElement.Use(itemAction); } } } } } if (inventoryElement.name == "" && cachedItem != null) { if (acceptedTypes.Exists(x => x.ID == cachedItem.type.ID || x.isAncestorOf(cachedItem.type))) { //For Stats/Fields cachedItem.UnEquip(); //For Method foreach (ElementAction itemAction in inventoryElement.actions) { if (itemAction.activateOnUnEquip) { inventoryElement.Use(itemAction); } } } cachedItem = null; } } } //If slot is active if (gameObject.activeSelf) { //Called when 'Play' is live if (Application.isPlaying) { activationCharacter = activationCharacters[activationInt]; //If activation char has a value if (activationCharacter != "None") { //If you press activation char if (Input.GetKeyDown(activationCharacter.ToLower())) { //On Hotkey //If the slot has an item if (inventoryElement.name != "") { //For each action foreach (ElementAction itemAction in inventoryElement.actions) { if (itemAction.onHotkey) { //Reoccurring call if (itemAction.repeatingInvoke) { itemAction.currentlyRepeating = true; } else { inventoryElement.Use(itemAction); } } } } if (ifActivateOnHotkey) { //If there is a slot activated if (Slot.activatedSlot != null) { //Disable any currently repeating functions if (Slot.activatedSlot.inventoryElement != null) { foreach (ElementAction itemAction in Slot.activatedSlot.inventoryElement.actions) { itemAction.currentlyRepeating = false; } } foreach (ElementAction itemAction in Slot.activatedSlot.inventoryElement.actions) { //On Deactivation if (itemAction.useOnDeactivation) { //Reoccurring call if (itemAction.repeatingInvoke) { itemAction.currentlyRepeating = true; } else { Slot.activatedSlot.inventoryElement.Use(itemAction); } } } } //If it's this slot, then disable it if (Slot.activatedSlot == this) { if (changeSize) { rectTransform.sizeDelta -= changeSizeVector2; } if (changeTexture) { backgroundRawImage.texture = cachedTexture; cachedTexture = null; } Slot.activatedSlot = null; } else { Slot.activatedSlot = this; if (changeSize) { rectTransform.sizeDelta += changeSizeVector2; } if (changeTexture) { cachedTexture = backgroundRawImage.texture; backgroundRawImage.texture = changeTextureImage; } //If the slot has an item if (inventoryElement.name != "") { //For each action foreach (ElementAction itemAction in inventoryElement.actions) { if (itemAction.useOnActivation) { //Reoccurring call if (itemAction.repeatingInvoke) { itemAction.currentlyRepeating = true; } else { inventoryElement.Use(itemAction); } } } } } } } } //Repeating Invoke foreach (ElementAction itemAction in inventoryElement.actions) { if (itemAction.currentlyRepeating) { inventoryElement.Use(itemAction); } } //Process repeating Invoke if (Slot.activatedSlot == this) { //If there is an item if (inventoryElement.name != "") { //For each action foreach (ElementAction itemAction in inventoryElement.actions) { if (itemAction.respondToMouse0) { if (Input.GetMouseButtonDown(0)) { if (itemAction.repeatingInvoke) { itemAction.currentlyRepeating = true; } else { inventoryElement.Use(itemAction); } } } if (Slot.activatedSlot == this) { if (itemAction.respondToMouse1) { if (Input.GetMouseButtonDown(1)) { if (itemAction.repeatingInvoke) { itemAction.currentlyRepeating = true; } else { inventoryElement.Use(itemAction); } } } } } } } } if (activationCharacter != null && activationCharacter != "None") { activationCharacterText.enabled = true; activationCharacterText.text = activationCharacter; } else { if (activationCharacterText != null) { activationCharacterText.enabled = false; } } if (inventoryElement != null) { if (inventoryElement.slot != this) { inventoryElement.slot = this; } //If there IS an item if (inventoryElement.name != "") { //If it has an icon if (inventoryElement.icon != null) { slotRawIconImage.enabled = true; //Set Icon slotRawIconImage.texture = inventoryElement.icon; slotRawIconImage.rectTransform.sizeDelta = rectTransform.sizeDelta - new Vector2(8, 8); } if (InventoryManager.Instance != null) { if (InventoryManager.Instance.stackingActive && inventoryElement.stack > 1) { stackGO.SetActive(true); if (stackText.font == null) { stackText.font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf"); } stackText.text = inventoryElement.stack.ToString(); } else { stackText.text = string.Empty; } } } else { stackGO.SetActive(false); //Destroy RawImage if (slotRawIconImage != null) { slotRawIconImage.enabled = false; } } } //Slot text if (slotText != null) { if (inventoryElement != null) { if (disableTextIfItem && inventoryElement.name != "") { slotText.enabled = false; } else { slotText.enabled = true; } } } } }
public void onTextureset(Texture tex) { img.material.mainTexture = tex; }
private static void CreateNotification(CharacterBody body, string title, string description, Texture texture) { var notification = body.gameObject.AddComponent <Notification>(); if (notification) { notification.transform.SetParent(body.transform); float x = Screen.width * 0.8f; float y = Screen.height * 0.25f; notification.SetPosition(new Vector3(x, y, 0)); notification.SetIcon(texture); notification.GetTitle = () => title; notification.GetDescription = () => description; UnityEngine.Object.Destroy(notification, 4.25f); } }
public override void OnGUI() { var rect = EditorGUILayout.BeginHorizontal(); GUILayout.Space(45); EditorGUILayout.BeginVertical(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(level.name); Color origColor = GUI.color; GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.5f); EditorGUILayout.LabelField(level.sceneName); GUI.color = origColor; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); Texture texture = textureOther; switch (level.type) { case MadLevel.Type.Other: texture = textureOther; break; case MadLevel.Type.Level: texture = textureLevel; break; case MadLevel.Type.Extra: texture = textureExtra; break; default: Debug.LogError("Unknown level type: " + level.type); break; } if (!level.IsValid()) { texture = textureError; } GUI.DrawTexture(new Rect(rect.x, rect.y, 28, 34), texture); if (level.hasExtension) { GUI.DrawTexture(new Rect(rect.x, rect.y, 28, 34), textureStar); } // draw lock if (level.type == MadLevel.Type.Level) { Texture lockTexture = level.lockedByDefault ? textureLock : textureLockUnlocked; GUI.DrawTexture(new Rect(rect.x + 22, rect.y, 28, 34), lockTexture); } EditorGUILayout.EndHorizontal(); }
public bool Contains(Texture key) { return(_contentByTextureDict.ContainsKey(key)); }
protected virtual bool BackgroundStillValid(Texture b) => b == null || b.Available;
/// <summary> /// Advanced sprite fill function. Contributed by Nicki Hansen. /// </summary> void AdvancedFill(BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols) { Texture tex = mainTexture; if (tex == null) { return; } Vector4 br = border * pixelSize; if (br.x == 0f && br.y == 0f && br.z == 0f && br.w == 0f) { SimpleFill(verts, uvs, cols); return; } Color32 c = drawingColor; Vector4 v = drawingDimensions; Vector2 tileSize = new Vector2(mInnerUV.width * tex.width, mInnerUV.height * tex.height); tileSize *= pixelSize; if (tileSize.x < 1f) { tileSize.x = 1f; } if (tileSize.y < 1f) { tileSize.y = 1f; } mTempPos[0].x = v.x; mTempPos[0].y = v.y; mTempPos[3].x = v.z; mTempPos[3].y = v.w; if (mFlip == Flip.Horizontally || mFlip == Flip.Both) { mTempPos[1].x = mTempPos[0].x + br.z; mTempPos[2].x = mTempPos[3].x - br.x; mTempUVs[3].x = mOuterUV.xMin; mTempUVs[2].x = mInnerUV.xMin; mTempUVs[1].x = mInnerUV.xMax; mTempUVs[0].x = mOuterUV.xMax; } else { mTempPos[1].x = mTempPos[0].x + br.x; mTempPos[2].x = mTempPos[3].x - br.z; mTempUVs[0].x = mOuterUV.xMin; mTempUVs[1].x = mInnerUV.xMin; mTempUVs[2].x = mInnerUV.xMax; mTempUVs[3].x = mOuterUV.xMax; } if (mFlip == Flip.Vertically || mFlip == Flip.Both) { mTempPos[1].y = mTempPos[0].y + br.w; mTempPos[2].y = mTempPos[3].y - br.y; mTempUVs[3].y = mOuterUV.yMin; mTempUVs[2].y = mInnerUV.yMin; mTempUVs[1].y = mInnerUV.yMax; mTempUVs[0].y = mOuterUV.yMax; } else { mTempPos[1].y = mTempPos[0].y + br.y; mTempPos[2].y = mTempPos[3].y - br.w; mTempUVs[0].y = mOuterUV.yMin; mTempUVs[1].y = mInnerUV.yMin; mTempUVs[2].y = mInnerUV.yMax; mTempUVs[3].y = mOuterUV.yMax; } for (int x = 0; x < 3; ++x) { int x2 = x + 1; for (int y = 0; y < 3; ++y) { if (centerType == AdvancedType.Invisible && x == 1 && y == 1) { continue; } int y2 = y + 1; if (x == 1 && y == 1) // Center { if (centerType == AdvancedType.Tiled) { float startPositionX = mTempPos[x].x; float endPositionX = mTempPos[x2].x; float startPositionY = mTempPos[y].y; float endPositionY = mTempPos[y2].y; float textureStartX = mTempUVs[x].x; float textureStartY = mTempUVs[y].y; float tileStartY = startPositionY; while (tileStartY < endPositionY) { float tileStartX = startPositionX; float textureEndY = mTempUVs[y2].y; float tileEndY = tileStartY + tileSize.y; if (tileEndY > endPositionY) { textureEndY = Mathf.Lerp(textureStartY, textureEndY, (endPositionY - tileStartY) / tileSize.y); tileEndY = endPositionY; } while (tileStartX < endPositionX) { float tileEndX = tileStartX + tileSize.x; float textureEndX = mTempUVs[x2].x; if (tileEndX > endPositionX) { textureEndX = Mathf.Lerp(textureStartX, textureEndX, (endPositionX - tileStartX) / tileSize.x); tileEndX = endPositionX; } Fill(verts, uvs, cols, tileStartX, tileEndX, tileStartY, tileEndY, textureStartX, textureEndX, textureStartY, textureEndY, c); tileStartX += tileSize.x; } tileStartY += tileSize.y; } } else if (centerType == AdvancedType.Sliced) { Fill(verts, uvs, cols, mTempPos[x].x, mTempPos[x2].x, mTempPos[y].y, mTempPos[y2].y, mTempUVs[x].x, mTempUVs[x2].x, mTempUVs[y].y, mTempUVs[y2].y, c); } } else if (x == 1) // Top or bottom { if ((y == 0 && bottomType == AdvancedType.Tiled) || (y == 2 && topType == AdvancedType.Tiled)) { float startPositionX = mTempPos[x].x; float endPositionX = mTempPos[x2].x; float startPositionY = mTempPos[y].y; float endPositionY = mTempPos[y2].y; float textureStartX = mTempUVs[x].x; float textureStartY = mTempUVs[y].y; float textureEndY = mTempUVs[y2].y; float tileStartX = startPositionX; while (tileStartX < endPositionX) { float tileEndX = tileStartX + tileSize.x; float textureEndX = mTempUVs[x2].x; if (tileEndX > endPositionX) { textureEndX = Mathf.Lerp(textureStartX, textureEndX, (endPositionX - tileStartX) / tileSize.x); tileEndX = endPositionX; } Fill(verts, uvs, cols, tileStartX, tileEndX, startPositionY, endPositionY, textureStartX, textureEndX, textureStartY, textureEndY, c); tileStartX += tileSize.x; } } else if ((y == 0 && bottomType == AdvancedType.Sliced) || (y == 2 && topType == AdvancedType.Sliced)) { Fill(verts, uvs, cols, mTempPos[x].x, mTempPos[x2].x, mTempPos[y].y, mTempPos[y2].y, mTempUVs[x].x, mTempUVs[x2].x, mTempUVs[y].y, mTempUVs[y2].y, c); } } else if (y == 1) // Left or right { if ((x == 0 && leftType == AdvancedType.Tiled) || (x == 2 && rightType == AdvancedType.Tiled)) { float startPositionX = mTempPos[x].x; float endPositionX = mTempPos[x2].x; float startPositionY = mTempPos[y].y; float endPositionY = mTempPos[y2].y; float textureStartX = mTempUVs[x].x; float textureEndX = mTempUVs[x2].x; float textureStartY = mTempUVs[y].y; float tileStartY = startPositionY; while (tileStartY < endPositionY) { float textureEndY = mTempUVs[y2].y; float tileEndY = tileStartY + tileSize.y; if (tileEndY > endPositionY) { textureEndY = Mathf.Lerp(textureStartY, textureEndY, (endPositionY - tileStartY) / tileSize.y); tileEndY = endPositionY; } Fill(verts, uvs, cols, startPositionX, endPositionX, tileStartY, tileEndY, textureStartX, textureEndX, textureStartY, textureEndY, c); tileStartY += tileSize.y; } } else if ((x == 0 && leftType == AdvancedType.Sliced) || (x == 2 && rightType == AdvancedType.Sliced)) { Fill(verts, uvs, cols, mTempPos[x].x, mTempPos[x2].x, mTempPos[y].y, mTempPos[y2].y, mTempUVs[x].x, mTempUVs[x2].x, mTempUVs[y].y, mTempUVs[y2].y, c); } } else // Corner { if ((y == 0 && bottomType == AdvancedType.Sliced) || (y == 2 && topType == AdvancedType.Sliced) || (x == 0 && leftType == AdvancedType.Sliced) || (x == 2 && rightType == AdvancedType.Sliced)) { Fill(verts, uvs, cols, mTempPos[x].x, mTempPos[x2].x, mTempPos[y].y, mTempPos[y2].y, mTempUVs[x].x, mTempUVs[x2].x, mTempUVs[y].y, mTempUVs[y2].y, c); } } } } }
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader) { // Cache old shader properties with potentially different names than the new shader. float? smoothness = GetFloatProperty(material, "_Glossiness"); float? diffuse = GetFloatProperty(material, "_UseDiffuse"); float? specularHighlights = GetFloatProperty(material, "_SpecularHighlights"); float? normalMap = null; Texture normalMapTexture = material.GetTexture("_BumpMap"); float? normalMapScale = GetFloatProperty(material, "_BumpScale"); float? emission = null; Color? emissionColor = GetColorProperty(material, "_EmissionColor"); float? reflections = null; float? rimLighting = null; Vector4? textureScaleOffset = null; float? cullMode = GetFloatProperty(material, "_Cull"); if (oldShader) { if (oldShader.name.Contains("Standard")) { normalMap = material.IsKeywordEnabled("_NORMALMAP") ? 1.0f : 0.0f; emission = material.IsKeywordEnabled("_EMISSION") ? 1.0f : 0.0f; reflections = GetFloatProperty(material, "_GlossyReflections"); } else if (oldShader.name.Contains("Fast Configurable")) { normalMap = material.IsKeywordEnabled("_USEBUMPMAP_ON") ? 1.0f : 0.0f; emission = GetFloatProperty(material, "_UseEmissionColor"); reflections = GetFloatProperty(material, "_UseReflections"); rimLighting = GetFloatProperty(material, "_UseRimLighting"); textureScaleOffset = GetVectorProperty(material, "_TextureScaleOffset"); } } base.AssignNewShaderToMaterial(material, oldShader, newShader); // Apply old shader properties to the new shader. SetShaderFeatureActive(material, null, "_Smoothness", smoothness); SetShaderFeatureActive(material, "_DIRECTIONAL_LIGHT", "_DirectionalLight", diffuse); SetShaderFeatureActive(material, "_SPECULAR_HIGHLIGHTS", "_SpecularHighlights", specularHighlights); SetShaderFeatureActive(material, "_NORMAL_MAP", "_EnableNormalMap", normalMap); if (normalMapTexture) { material.SetTexture("_NormalMap", normalMapTexture); } SetShaderFeatureActive(material, null, "_NormalMapScale", normalMapScale); SetShaderFeatureActive(material, "_EMISSION", "_EnableEmission", emission); SetColorProperty(material, "_EmissiveColor", emissionColor); SetShaderFeatureActive(material, "_REFLECTIONS", "_Reflections", reflections); SetShaderFeatureActive(material, "_RIM_LIGHT", "_RimLight", rimLighting); SetVectorProperty(material, "_MainTex_ST", textureScaleOffset); SetShaderFeatureActive(material, null, "_CullMode", cullMode); // Setup the rendering mode based on the old shader. if (oldShader == null || !oldShader.name.Contains(LegacyShadersPath)) { SetupMaterialWithRenderingMode(material, (RenderingMode)material.GetFloat(BaseStyles.renderingModeName), CustomRenderingMode.Opaque, -1); } else { RenderingMode mode = RenderingMode.Opaque; if (oldShader.name.Contains(TransparentCutoutShadersPath)) { mode = RenderingMode.Cutout; } else if (oldShader.name.Contains(TransparentShadersPath)) { mode = RenderingMode.Fade; } material.SetFloat(BaseStyles.renderingModeName, (float)mode); MaterialChanged(material); } }
//public void SetColor(Color color) //{ // _sprite.SetColor(color); //} public MoveChess(Texture moveChessTexture) { _sprite.Texture = moveChessTexture; // Some default values bool Dead = false; }
private void load(ShaderManager shaders, TextureStore textures) { shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.Texture); texture = textures.Get(@"Cursor/cursortrail"); }
public IEnumerable <TextureReplacement> CreateTextureReplacements(Part part, Action <string> onError) { part.ThrowIfNullArgument(nameof(part)); if (string.IsNullOrEmpty(newTexturePath)) { onError("texture name is empty"); yield break; } Texture newTexture = GameDatabase.Instance.GetTexture(newTexturePath, isNormalMap); if (newTexture == null) { onError($"Texture '{newTexturePath}' not found!"); yield break; } string shaderProperty = shaderPropName; if (string.IsNullOrEmpty(shaderProperty)) { if (isNormalMap) { shaderProperty = "_BumpMap"; } else { shaderProperty = "_MainTex"; } } IEnumerable <Renderer> renderers; if (baseTransformNames.IsNullOrEmpty() && transformNames.IsNullOrEmpty()) { renderers = part.GetModelRoot().GetComponentsInChildren <Renderer>(true); } else { renderers = GetBaseTransformRenderers(part, onError); renderers = renderers.Concat(GetTransformRenderers(part, onError)); renderers = renderers.Distinct(); } foreach (Renderer renderer in renderers) { Material sharedMaterial = renderer.sharedMaterial; Texture texture = sharedMaterial.GetTexture(shaderProperty); if (texture == null) { continue; } if (!currentTextureName.IsNullOrEmpty()) { string baseTextureName = texture.name.Substring(texture.name.LastIndexOf('/') + 1); if (baseTextureName != currentTextureName) { continue; } } yield return(new TextureReplacement(renderer, shaderProperty, newTexture)); } }
/// <summary> /// Tiled sprite fill function. /// </summary> void TiledFill(BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols) { Texture tex = mainTexture; if (tex == null) { return; } Vector2 size = new Vector2(mInnerUV.width * tex.width, mInnerUV.height * tex.height); size *= pixelSize; if (tex == null || size.x < 2f || size.y < 2f) { return; } Color32 c = drawingColor; Vector4 v = drawingDimensions; Vector4 u; if (mFlip == Flip.Horizontally || mFlip == Flip.Both) { u.x = mInnerUV.xMax; u.z = mInnerUV.xMin; } else { u.x = mInnerUV.xMin; u.z = mInnerUV.xMax; } if (mFlip == Flip.Vertically || mFlip == Flip.Both) { u.y = mInnerUV.yMax; u.w = mInnerUV.yMin; } else { u.y = mInnerUV.yMin; u.w = mInnerUV.yMax; } float x0 = v.x; float y0 = v.y; float u0 = u.x; float v0 = u.y; while (y0 < v.w) { x0 = v.x; float y1 = y0 + size.y; float v1 = u.w; if (y1 > v.w) { v1 = Mathf.Lerp(u.y, u.w, (v.w - y0) / size.y); y1 = v.w; } while (x0 < v.z) { float x1 = x0 + size.x; float u1 = u.z; if (x1 > v.z) { u1 = Mathf.Lerp(u.x, u.z, (v.z - x0) / size.x); x1 = v.z; } verts.Add(new Vector3(x0, y0)); verts.Add(new Vector3(x0, y1)); verts.Add(new Vector3(x1, y1)); verts.Add(new Vector3(x1, y0)); uvs.Add(new Vector2(u0, v0)); uvs.Add(new Vector2(u0, v1)); uvs.Add(new Vector2(u1, v1)); uvs.Add(new Vector2(u1, v0)); cols.Add(c); cols.Add(c); cols.Add(c); cols.Add(c); x0 += size.x; } y0 += size.y; } }
internal static void DrawPreview(Rect r, Texture texture) { GUI.DrawTexture(r, texture, ScaleMode.StretchToFill, false); }
public void GetButtonTextAndIconFromType(ButtonTypeEnum type, out string buttonText, out Texture buttonIcon, out int displayOrder) { switch (type) { case ButtonTypeEnum.Show: buttonText = "Show"; buttonIcon = showIcon; displayOrder = 0; break; case ButtonTypeEnum.Hide: buttonText = "Hide"; buttonIcon = hideIcon; displayOrder = 1; break; case ButtonTypeEnum.Adjust: buttonText = "Adjust"; buttonIcon = adjustIcon; displayOrder = 2; break; case ButtonTypeEnum.Remove: buttonText = "Remove"; buttonIcon = removeIcon; displayOrder = 3; break; case ButtonTypeEnum.Done: buttonText = "Done"; buttonIcon = doneIcon; displayOrder = 4; break; default: throw new ArgumentOutOfRangeException("type", type, null); } }
public static GameObject CreateButton(string name, string text, Vector2 minAnchor, Vector2 maxAnchor, Transform parent = null, Font font = null, Color fontColor = new Color(), Color buttonColor = new Color(), int fontSize = 10, Sprite sprite = null, Texture texture = null, UnityEngine.Events.UnityAction method = null) { GameObject buttonGO = new GameObject(name); buttonGO.transform.SetParent(parent, false); buttonGO.AddComponent <RectTransform>(); if (texture) { RawImage rawImage = buttonGO.AddComponent <RawImage>(); rawImage.texture = texture; rawImage.color = buttonColor; } else { Image image = buttonGO.AddComponent <Image>(); image.sprite = sprite; image.color = buttonColor; } Button b = buttonGO.AddComponent <Button>(); b.onClick.AddListener(method); RectTransform rectTransform = buttonGO.GetComponent <RectTransform>(); rectTransform.anchorMin = minAnchor; rectTransform.anchorMax = maxAnchor; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; rectTransform.localScale = Vector3.one; rectTransform.localRotation = Quaternion.identity; if (text != "") { CreateText("Text", text, Vector2.zero, Vector2.one, buttonGO.transform, font, fontColor, fontSize); } return(buttonGO); }
public void Update() { // Get latest texture if ( GetComponent <Renderer>() != null && GetComponent <Renderer>().sharedMaterial != null) { Atlas = GetComponent <Renderer>().sharedMaterial.GetTexture("_MainTex"); // If received new image, make sure it's uptimized and stuff if (_previousAtlas != Atlas) { PrepNewTexture(); } } // Get new cell bounds and scaling from layout and animationSet LayoutData curLayoutData = DefaultLayoutData; var layoutComponent = GetComponent <BbSpriteLayout>(); if (layoutComponent != null && layoutComponent.enabled) { curLayoutData = layoutComponent.MyLayoutData; } int currentCell = 0; var animation = GetComponent <BbSpriteAnimation>(); if (animation != null && animation.enabled) { currentCell = animation.CurrentCell; } _cellBounds = curLayoutData.GetCell( currentCell, (_spriteToCamRotation.y - transform.eulerAngles.y + 360) % 360); _scale = curLayoutData.GetCellScale(currentCell, Atlas); // Check for reason to update the mesh var dirtyMesh = false; if (_previousAtlas != Atlas) { _previousAtlas = Atlas; dirtyMesh = true; } if (_previousYRotation != transform.eulerAngles.y) { _previousYRotation = transform.eulerAngles.y; dirtyMesh = true; } if (_previousCellBounds != _cellBounds) { _previousCellBounds = _cellBounds; dirtyMesh = true; } if (_previousMyFacingType != MyFacingType) { _previousMyFacingType = MyFacingType; dirtyMesh = true; } if (_previousScale != _scale) { _previousScale = _scale; var cCollider = GetComponent <CapsuleCollider>(); if (cCollider != null) { cCollider.center = new Vector3(0, _scale.y / 2, 0); cCollider.radius = _scale.x / 2; cCollider.height = _scale.y; } dirtyMesh = true; } if (_previousSpriteToCamRotation != _spriteToCamRotation) { _previousSpriteToCamRotation = _spriteToCamRotation; dirtyMesh = true; } if (_previousVerticalOffset != VerticalOffset) { _previousVerticalOffset = VerticalOffset; dirtyMesh = true; } if (dirtyMesh) { UpdateMesh(); } }
private string createMaterial(Material mat) { MeshPhongMaterial3JS matJS = new MeshPhongMaterial3JS(); matJS.name = mat.name; // Colors matJS.color = Utils.getIntColor(mat.color); if (mat.HasProperty("_SpecColor")) { matJS.specular = Utils.getIntColor(mat.GetColor("_SpecColor")); } if (mat.HasProperty("_EmissionColor")) { mat.EnableKeyword("_EMISSION"); matJS.emissive = Utils.getIntColor(mat.GetColor("_EmissionColor")); matJS.emissiveIntensity = 1.0f; } // Values if (mat.HasProperty("_Emission")) { // Standrad shader doesn't have this value in Unity 5 :( // So set intensity of emission along with color //matJS.emissiveIntensity = mat.GetFloat("_Emission"); //matJS.emissiveIntensity = 1.0f; } if (mat.HasProperty("_Shininess")) { matJS.shininess = mat.GetFloat("_Shininess"); } // Maps // Main texture if (mat.HasProperty("_MainTex")) { Texture mainTexture = mat.GetTexture("_MainTex"); if (mainTexture != null) { string uuid = createTexture(mainTexture, mat); if (!string.IsNullOrEmpty(uuid)) { matJS.map = uuid; } } } // Normal map if (mat.HasProperty("_BumpMap")) { Texture normalMap = mat.GetTexture("_BumpMap"); if (normalMap != null) { string uuid = createTexture(normalMap, mat); if (!string.IsNullOrEmpty(uuid)) { matJS.normalMap = uuid; } } } // Emissive map if (mat.HasProperty("_EmissionMap")) { Texture emissionMap = mat.GetTexture("_EmissionMap"); if (emissionMap != null) { string uuid = createTexture(emissionMap, mat); if (!string.IsNullOrEmpty(uuid)) { matJS.emissiveMap = uuid; } } } // Specualar map if (mat.HasProperty("_SpecGlossMap")) { Texture specularMap = mat.GetTexture("_SpecGlossMap"); if (specularMap != null) { string uuid = createTexture(specularMap, mat); if (!string.IsNullOrEmpty(uuid)) { matJS.specularMap = uuid; } } } // Opacity and wireframe matJS.opacity = mat.color.a; // 0 = Opaque, 1 = Cutout, 2 = Fade, 3 = Transparent. // (At the time of version 5.4.0f3) matJS.transparent = (mat.GetFloat("_Mode") != 0); matJS.wireframe = false; if (options.forceDoubleSidedMaterials) { matJS.side = MaterialSide.DoubleSide; } content.materials.Add(matJS); materials.Add(matJS.uuid, mat); return(matJS.uuid); }
private void OnRenderImage(RenderTexture source, RenderTexture destination) { if (this.profile == null || this.m_Camera == null) { Graphics.Blit(source, destination); return; } bool flag = false; bool active = this.m_Fxaa.active; bool flag2 = this.m_Taa.active && !this.m_RenderingInSceneView; bool flag3 = this.m_DepthOfField.active && !this.m_RenderingInSceneView; Material material = this.m_MaterialFactory.Get("Hidden/Post FX/Uber Shader"); material.shaderKeywords = null; RenderTexture renderTexture = source; if (flag2) { RenderTexture renderTexture2 = this.m_RenderTextureFactory.Get(renderTexture); this.m_Taa.Render(renderTexture, renderTexture2); renderTexture = renderTexture2; } Texture autoExposure = null; if (this.m_EyeAdaptation.active) { flag = true; autoExposure = this.m_EyeAdaptation.Prepare(renderTexture, material); } if (flag3) { flag = true; this.m_DepthOfField.Prepare(renderTexture, material, flag2); } if (this.m_Bloom.active) { flag = true; this.m_Bloom.Prepare(renderTexture, material, autoExposure); } flag |= this.TryPrepareUberImageEffect <ChromaticAberrationModel>(this.m_ChromaticAberration, material); flag |= this.TryPrepareUberImageEffect <ColorGradingModel>(this.m_ColorGrading, material); flag |= this.TryPrepareUberImageEffect <UserLutModel>(this.m_UserLut, material); flag |= this.TryPrepareUberImageEffect <GrainModel>(this.m_Grain, material); flag |= this.TryPrepareUberImageEffect <VignetteModel>(this.m_Vignette, material); if (flag) { if (!GraphicsUtils.isLinearColorSpace) { material.EnableKeyword("UNITY_COLORSPACE_GAMMA"); } RenderTexture renderTexture3 = renderTexture; RenderTexture renderTexture4 = destination; if (active) { renderTexture4 = this.m_RenderTextureFactory.Get(renderTexture); renderTexture = renderTexture4; } Graphics.Blit(renderTexture3, renderTexture4, material, 0); } if (active) { this.m_Fxaa.Render(renderTexture, destination); } if (!flag && !active) { Graphics.Blit(renderTexture, destination); } this.m_RenderTextureFactory.ReleaseAll(); }
//Make a toggle button to change the mode of the editor. public void DoModeButton(Mode toMode, Texture icon) { var rect = EditorGUILayout.GetControlRect(Style.maxHButton, Style.maxWButton); actualMode = GUI.Toggle(rect, toMode == actualMode, icon, EditorStyles.miniButton) ? toMode : actualMode; }
public static GameObject CreatePanel(string name, Vector2 minAnchor, Vector2 maxAnchor, Transform parent, Sprite sprite = null, Texture texture = null, Color color = new Color()) { GameObject panelGO = new GameObject(name); panelGO.transform.parent = parent; panelGO.AddComponent <RectTransform>(); RectTransform rectTransform = panelGO.GetComponent <RectTransform>(); rectTransform.anchorMin = minAnchor; rectTransform.anchorMax = maxAnchor; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; if (texture) { RawImage rawImage = panelGO.AddComponent <RawImage>(); rawImage.texture = texture; rawImage.color = color; } else { Image image = panelGO.AddComponent <Image>(); image.sprite = sprite; image.color = color; } return(panelGO); }
private void ApplyTextureToMaterial(Material material, Texture texture) { material.SetTexture(Shader.PropertyToID("_MainTex"), texture); }
private void NewListItem (Texture pic, string name) { }