public void LoadImage(string imageName) { if (ResourceLoader == null) throw new InvalidOperationException("Resource Loader is not set for this image control. Cannot load " + imageName); Texture = ResourceLoader.LoadResource(imageName); }
static bool HorizontalScope_HorizontalScope4(JSVCall vc, int argc) { int _this = JSApi.getObject((int)JSApi.GetType.Arg); JSApi.attachFinalizerObject(_this); --argc; int len = argc; if (len == 3) { UnityEngine.Texture arg0 = (UnityEngine.Texture)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUIStyle arg1 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUILayoutOption[] arg2 = JSDataExchangeMgr.GetJSArg <UnityEngine.GUILayoutOption[]>(() => { int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg); int length = JSApi.getArrayLength(jsObjID); var ret = new UnityEngine.GUILayoutOption[length]; for (var i = 0; i < length; i++) { JSApi.getElement(jsObjID, i); ret[i] = (UnityEngine.GUILayoutOption)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove); } return(ret); }); JSMgr.addJSCSRel(_this, new UnityEngine.GUILayout.HorizontalScope(arg0, arg1, arg2)); } return(true); }
public static bool SaveAsPng(this UnityEngine.Texture texture, string fileName) { Texture2D texture2D = texture as Texture2D; if (texture2D == null) { return(false); } byte[] pNG = null; try { pNG = texture2D.EncodeToPNG(); } catch (UnityException unityException) { } if (pNG == null) { Texture2D texture2D1 = Facepunch.Utility.Texture.CreateReadableCopy(texture2D, 0, 0); pNG = texture2D1.EncodeToPNG(); UnityEngine.Object.DestroyImmediate(texture2D1); } if (pNG == null) { return(false); } if (File.Exists(fileName)) { File.Delete(fileName); } File.WriteAllBytes(fileName, pNG); return(true); }
public static bool IsNormalMap(Texture t) { TextureUsageMode usageMode = TextureUtil.GetUsageMode(t); if (usageMode != TextureUsageMode.NormalmapPlain) return usageMode == TextureUsageMode.NormalmapDXT5nm; return true; }
internal void applyRenderTexture(Rect screenRect, Texture texture, Material mat) { #if !UNITY_2019_2_OR_NEWER this.texture = texture; this.material = mat; #endif }
static NormalTextureInfo ExportNormalTextureInfo( UnityEngine.Texture texture, TextureMapType textureMapType, UnityEngine.Material material, IGltfWritable gltf ) { var imageId = gltf.AddImage(texture); if (imageId < 0) { return(null); } var textureId = gltf.AddTexture(imageId); var info = new NormalTextureInfo { index = textureId, // texCoord = 0 // TODO: figure out which UV set was used }; if (material.HasProperty(MaterialGenerator.bumpScalePropId)) { info.scale = material.GetFloat(MaterialGenerator.bumpScalePropId); } return(info); }
private void Awake() { myRenderer = GetComponentInChildren<Renderer> (); originalTexture = myRenderer.material.mainTexture; SetStartPosition (startPosition); InitMapObjectType(); }
public static void SetWindowValues(EditorWindow editor, Texture icon, string title) { GUIContent guiContent; if (m_windowContentDict == null) m_windowContentDict = new Dictionary<EditorWindow, GUIContent>(); if (m_windowContentDict.ContainsKey(editor)) { guiContent = m_windowContentDict[editor]; if (guiContent != null) { if (guiContent.image != icon) guiContent.image = icon; if (title != null && guiContent.text != title) guiContent.text = title; return; } m_windowContentDict.Remove(editor); } guiContent = getContent(editor); if (guiContent != null) { if (guiContent.image != icon) guiContent.image = icon; if (title != null && guiContent.text != title) guiContent.text = title; m_windowContentDict.Add(editor, guiContent); } }
static public int constructor(IntPtr l) { UnityEngine.Texture o; o = new UnityEngine.Texture(); pushObject(l, o); return(1); }
public override void Reset() { text = ""; image = null; tooltip = ""; style = ""; }
internal VideoStreamTrack(string label, UnityEngine.Texture source, UnityEngine.RenderTexture dest, int width, int height) : this(label, dest.GetNativeTexturePtr(), width, height) { m_needFlip = true; m_sourceTexture = source; m_destTexture = dest; }
public void Enable(bool value, float duration) { if (Enabled != value) { collider.enabled = value; if (duration > 0) { TweenColor.Begin(gameObject, duration, value ? ColorUp : ColorDisabled).animationCurve = AnimationCurve; TweenScale.Begin(gameObject, duration, Vector3.one).animationCurve = AnimationCurve; } else { GetComponent<UIWidget>().color = value ? ColorUp : ColorDisabled; transform.localScale = Vector3.one; } if (TextureDisabled == null) return; if (Texture == null) { Texture = GetComponent<UIWidget>().mainTexture; } GetComponent<UIWidget>().mainTexture = value ? Texture : TextureDisabled; } }
public override void OnFlowSettingsGUI() { if (Heatmap.settings == null) { Heatmap.settings = this.GetSettingsFile(); //if (Heatmap.settings == null) Heatmap.settings = ME.EditorUtilities.GetAssetsOfType<HeatmapSettings>(useCache: false).FirstOrDefault(); } if (this.noDataTexture == null) this.noDataTexture = Resources.Load("UI.Windows/Heatmap/NoData") as Texture; var settings = Heatmap.settings; if (settings == null) { EditorGUILayout.HelpBox(string.Format(FlowAddon.MODULE_HAS_ERRORS, "Settings file not found (HeatmapSettings)."), MessageType.Error); } else { GUILayout.Label(FlowAddon.MODULE_INSTALLED, EditorStyles.centeredGreyMiniLabel); if (this.editor == null) this.editor = Editor.CreateEditor(settings); if (this.editor != null) { this.editor.OnInspectorGUI(); } } }
private TextureId ExportTexture(UnityEngine.Texture textureObj) { TextureId id = GetTextureId(_root, textureObj); if (id != null) { return(id); } var texture = new GLTF.Schema.Texture(); if (ExportNames) { texture.Name = textureObj.name; } texture.Source = ExportImage(textureObj); texture.Sampler = ExportSampler(textureObj); _textures.Add(textureObj); id = new TextureId { Id = _root.Textures.Count, Root = _root }; _root.Textures.Add(texture); return(id); }
public override void Reset() { base.Reset(); this.tempTexture = null; }
public static void registerItem(String id, Texture invTexture, GameObject model) { if (items.ContainsKey(id)) throw new Exception("Cannot have two items with the same id (" + id + ")"); items[id] = new ItemData(invTexture, model); }
public EventHandlerDesc(string name, Type type, Texture icon, string tooltip) { Name = name; Type = type; Icon = icon; Tooltip = tooltip; }
public override void Reset() { gameObject = null; materialIndex = 0; namedTexture = "_MainTex"; texture = null; }
public static void DrawBackground(Rect position, Texture image, float scale = 0.15f) { float texWidth = image.width * scale; GUI.BeginGroup (position); // Top Left Region GUI.DrawTextureWithTexCoords (new Rect (0, 0, texWidth, texWidth), image, new Rect (0, 1 - scale, scale, scale)); // Top Center Region GUI.DrawTextureWithTexCoords (new Rect (texWidth, 0, position.width - texWidth * 2, texWidth), image, new Rect (1 - scale, 1 - scale, 0, scale)); // Top Right Region GUI.DrawTextureWithTexCoords (new Rect (position.width - texWidth, 0, texWidth, texWidth), image, new Rect (1 - scale, 1 - scale, scale, scale)); // Middle Left Region GUI.DrawTextureWithTexCoords (new Rect (0, texWidth, texWidth, position.height - texWidth * 2), image, new Rect (0, 1 - scale, scale, 0)); // Middle Center Region GUI.DrawTextureWithTexCoords (new Rect (texWidth, texWidth, position.width - texWidth * 2, position.height - texWidth * 2), image, new Rect (0.5f, 0.5f, 0, 0)); // Middle Right Region GUI.DrawTextureWithTexCoords (new Rect (position.width - texWidth, texWidth, texWidth, position.height - texWidth * 2), image, new Rect (1 - scale, 1 - scale, scale, 0)); // Bottom Left Region GUI.DrawTextureWithTexCoords (new Rect (0, position.height - texWidth, texWidth, texWidth), image, new Rect (0, 0, scale, scale)); // Bottom Center Region GUI.DrawTextureWithTexCoords (new Rect (texWidth, position.height - texWidth, position.width - texWidth * 2, texWidth), image, new Rect (1 - scale, 0, 0, scale)); // Bottom Right Region GUI.DrawTextureWithTexCoords (new Rect (position.width - texWidth, position.height - texWidth, texWidth, texWidth), image, new Rect (1 - scale, 0, scale, scale)); GUI.EndGroup (); }
private void SetAwardItem(List <PrizeItemConfig> items) { if (items == null || items.Count <= 0) { NGUITools.SetActive(goAwardItem, false); } else { PrizeItemConfig prizeItemCfg = items[0]; if (prizeItemCfg != null) { if (lblRankingAwardItem != null) { lblRankingAwardItem.text = "X " + prizeItemCfg.ItemNum; } int itemId = prizeItemCfg.ItemId; ItemConfig itemCfg = ItemConfigProvider.Instance.GetDataById(itemId); if (itemCfg == null) { return; } UnityEngine.Texture tex = CrossObjectHelper.TryCastObject <UnityEngine.Texture>(ResourceSystem.GetSharedResource(itemCfg.m_ItemTrueName)); if (texRankingAwardItem != null) { if (tex != null) { texRankingAwardItem.mainTexture = tex; } NGUITools.SetActive(goAwardItem, true); } } } }
public GUIContent(string text, Texture image) { this.m_Text = string.Empty; this.m_Tooltip = string.Empty; this.m_Text = text; this.m_Image = image; }
public GUIContent(Texture image, string tooltip) { this.m_Text = string.Empty; this.m_Tooltip = string.Empty; this.m_Image = image; this.m_Tooltip = tooltip; }
private ImageId ExportImage(UnityEngine.Texture texture, TextureMapType texturMapType) { ImageId id = GetImageId(_root, texture); if (id != null) { return(id); } var image = new Image(); if (ExportNames) { image.Name = texture.name; } _imageInfos.Add(new ImageInfo { texture = texture as Texture2D, textureMapType = texturMapType }); var path = _retrieveTexturePathDelegate(texture); var newPath = Path.ChangeExtension(path, ".png"); image.Uri = Uri.EscapeUriString(newPath); id = new ImageId { Id = _root.Images.Count, Root = _root }; _root.Images.Add(image); return(id); }
static bool Graphics_BlitMultiTap__Texture__RenderTexture__Material__Vector2_Array(JSVCall vc, int argc) { int len = argc; if (len == 4) { UnityEngine.Texture arg0 = (UnityEngine.Texture)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.RenderTexture arg1 = (UnityEngine.RenderTexture)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.Material arg2 = (UnityEngine.Material)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.Vector2[] arg3 = JSDataExchangeMgr.GetJSArg <UnityEngine.Vector2[]>(() => { int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg); int length = JSApi.getArrayLength(jsObjID); var ret = new UnityEngine.Vector2[length]; for (var i = 0; i < length; i++) { JSApi.getElement(jsObjID, i); ret[i] = (UnityEngine.Vector2)JSApi.getVector2S((int)JSApi.GetType.SaveAndRemove); } return(ret); }); UnityEngine.Graphics.BlitMultiTap(arg0, arg1, arg2, arg3); } return(true); }
} //GetBones private static void GetMeshes(Transform transform, List<SkinnedMeshRenderer> meshes, List<UnityEngine.Material> materials, List<UnityEngine.Texture> textures) { foreach (Transform t in transform) { if (t.GetComponent<SkinnedMeshRenderer>()) { SkinnedMeshRenderer mesh = t.gameObject.GetComponent<SkinnedMeshRenderer>(); meshes.Add(t.gameObject.GetComponent<SkinnedMeshRenderer>()); UnityEngine.Material material = mesh.sharedMaterial; if (!materials.Contains(material)) { materials.Add(material); if (material.HasProperty("_Base_Tex_SRGB")) { UnityEngine.Texture texture = material.GetTexture("_Base_Tex_SRGB"); if (texture != null) { if (!textures.Contains(texture)) { textures.Add(material.GetTexture("_Base_Tex_SRGB")); } //if } //if } //if } //if } //if } //foreach } //GetMeshes
static public int GetTexture(IntPtr l) { try{ if (matchType(l, 2, typeof(System.String))) { UnityEngine.Material self = (UnityEngine.Material)checkSelf(l); System.String a1; checkType(l, 2, out a1); UnityEngine.Texture ret = self.GetTexture(a1); pushValue(l, ret); return(1); } else if (matchType(l, 2, typeof(System.Int32))) { UnityEngine.Material self = (UnityEngine.Material)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); UnityEngine.Texture ret = self.GetTexture(a1); pushValue(l, ret); return(1); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
public DescriptorAttribute(string name, string description, Texture icon, Color color) { this.name = name; this.comment = description; this.icon = icon; this.color = color; }
public static bool HandleSetAndroidHighRes(string assetPath) { UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(assetPath, typeof(UnityEngine.Texture)); if (obj != null) { UnityEngine.Texture tex = obj as UnityEngine.Texture; int OldMaxSize = 0; if (tex.height >= tex.width) { OldMaxSize = tex.height; } else { OldMaxSize = tex.width; } TextureImporter textureImporter = (TextureImporter)AssetImporter.GetAtPath(assetPath); if (textureImporter != null) { if (textureImporter.textureFormat != TextureImporterFormat.ARGB16 || textureImporter.maxTextureSize != OldMaxSize) { textureImporter.textureFormat = TextureImporterFormat.ARGB16; UDebug.Log("$$ HighRes PNG textureFormat=>ARGB16"); textureImporter.maxTextureSize = OldMaxSize; AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate); EditorUtility.SetDirty(textureImporter); return(true); } } } return(false); }
/// <summary> /// Export a normal texture from Unity to glTF. /// </summary> /// <param name="texture">Normal texture to export</param> /// <param name="material">Material the normal is used on</param> /// <param name="gltf">Context glTF to export to</param> /// <returns>glTF texture info</returns> protected static NormalTextureInfo ExportNormalTextureInfo( UnityEngine.Texture texture, UnityEngine.Material material, IGltfWritable gltf ) { var texture2d = texture as Texture2D; if (texture2d == null) { return(null); } var imageExport = new NormalImageExport(texture2d); if (AddImageExport(gltf, imageExport, out var textureId)) { var info = new NormalTextureInfo { index = textureId, // texCoord = 0 // TODO: figure out which UV set was used }; if (material.HasProperty(MaterialGenerator.bumpScalePropId)) { info.scale = material.GetFloat(MaterialGenerator.bumpScalePropId); } return(info); } return(null); }
static public void LoadResources() { UnityPrimitiveCubeThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Cube.png"); UnityPrimitiveSphereThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Sphere.png"); UnityPrimitiveCylinderThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Cylinder.png"); UnityPrimitiveCapsuleThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Capsule.png"); UnityPrimitivePlaneThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Plane.png"); UnityPrimitiveQuadThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Quad.png"); UnityPrimitivePointlightThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Pointlight.png"); UnityPrimitiveArealightThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Arealight.png"); UnityPrimitiveSunlightThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Sunlight.png"); UnityPrimitiveSpotlightThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Spotlight.png"); UnityPrimitiveReflectionprobeThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Reflectionprobe.png"); UnityPrimitiveLightprobegroupThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Lightprobegroup.png"); UnityPrimitiveParticlesystemThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Particlesystem.png"); UnityPrimitiveAudioemitterThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Audioemitter.png"); UnityPrimitiveAudioreverbThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Audioreverb.png"); UnityPrimitiveCameraThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Camera.png"); UnityPrimitiveCameraviewportThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Cameraviewport.png"); UnityPrimitiveTreeThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Tree.png"); UnityPrimitiveLandscapeThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Landscape.png"); UnityPrimitiveSpriteThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Sprite.png"); UnityPrimitiveNullobjectThumb = (Texture)AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlus_Icon_Nullobject.png"); ButtonSize.x = UnityPrimitiveCubeThumb.width; ButtonSize.y = UnityPrimitiveCubeThumb.height; IconsSkin = AssetDatabase.LoadMainAssetAtPath(EditorPlus.PlusPath +EditorPlus.SelectedSkinFolder + "UnityPlusSkinIcons.guiskin") as GUISkin; if(window != null) window.Repaint(); }
public MemberDescriptor(string name, Type type, Texture icon, object @default = null) { Name = name; Type = type; Icon = icon; Default = @default; }
private async Task ExportTexture(Dictionary <string, string> data, string folder, int group, string paramname, Material mat, Material defaultMat, bool isNormalMap = false) { WorkshopItemEditor.Loading(true, string.Concat("Exporting Texture ", paramname), "", 0f); UnityEngine.Texture texture = mat.GetTexture(paramname); if (texture != defaultMat.GetTexture(paramname)) { if (texture != null) { texture = Facepunch.Utility.Texture.LimitSize(texture as Texture2D, this.Skinnable.Groups[group].MaxTextureSize, this.Skinnable.Groups[group].MaxTextureSize); if (isNormalMap) { texture = Facepunch.Utility.Texture.CreateReadableCopy(texture as Texture2D, 0, 0); (texture as Texture2D).DecompressNormals(); } string str = string.Format("{0}{1}{2}", paramname, group, ".png"); data.Add(paramname, str); texture.SaveAsPng(string.Concat(folder, "/", str)); await Task.Delay(1); } else { data.Add(paramname, "none"); } } }
void Start() { visibleColor = Color.white; invisibleColor = Color.clear; bioLogo = new Texture(); string PathPlugin = string.Format("{0}","BioMass"); string PathTextures = string.Format("{0}/Textures", PathPlugin); string imageFilename = String.Format("{0}/{1}", PathTextures, "logo-1"); if (GameDatabase.Instance.ExistsTexture(imageFilename)) { //new bioMsg("Load Texture: " + imageFilename); bioLogo = GameDatabase.Instance.GetTexture(imageFilename, false); } else { print("image not found" + imageFilename); } showLogo = false; logoObj = new GameObject(); logoObj.AddComponent<GUITexture>().texture = bioLogo; logoObj.GetComponent<GUITexture>().guiTexture.color = new Color(logoObj.GetComponent<GUITexture>().guiTexture.color.r,logoObj.GetComponent<GUITexture>().guiTexture.color.g, logoObj.GetComponent<GUITexture>().guiTexture.color.b, 0.0f); logoObj.transform.localPosition = new Vector3(0.495f,0.6f,1.0f); logoObj.transform.localScale = new Vector3(0.12f, 0.1f, 0.1f); //logoObj.transform.localRotation = new Quaternion(-30,0,0,0); StartCoroutine(logoTimerIn()); }
public SamplerId GetSamplerId(GLTFRoot root, UnityEngine.Texture textureObj) { for (var i = 0; i < root.Samplers.Count; i++) { bool filterIsNearest = root.Samplers[i].MinFilter == MinFilterMode.Nearest || root.Samplers[i].MinFilter == MinFilterMode.NearestMipmapNearest || root.Samplers[i].MinFilter == MinFilterMode.LinearMipmapNearest; bool filterIsLinear = root.Samplers[i].MinFilter == MinFilterMode.Linear || root.Samplers[i].MinFilter == MinFilterMode.NearestMipmapLinear; bool filterMatched = textureObj.filterMode == FilterMode.Point && filterIsNearest || textureObj.filterMode == FilterMode.Bilinear && filterIsLinear || textureObj.filterMode == FilterMode.Trilinear && root.Samplers[i].MinFilter == MinFilterMode.LinearMipmapLinear; bool wrapMatched = textureObj.wrapMode == TextureWrapMode.Clamp && root.Samplers[i].WrapS == GLTF.Schema.WrapMode.ClampToEdge || textureObj.wrapMode == TextureWrapMode.Repeat && root.Samplers[i].WrapS != GLTF.Schema.WrapMode.ClampToEdge; if (filterMatched && wrapMatched) { return(new SamplerId { Id = i, Root = root }); } } return(null); }
public ComponentTypeDesc(string name, Type type, Texture icon, string tooltip) { Name = name; Type = type; Icon = icon; Tooltip = tooltip; }
static void Texture_texelSize(JSVCall vc) { UnityEngine.Texture _this = (UnityEngine.Texture)vc.csObj; var result = _this.texelSize; JSApi.setVector2S((int)JSApi.SetType.Rval, result); }
public LegacyTexture(TextureData data, Texture texture) { InternalName = data.InternalName; Path = data.Path; AlphaTestValue = data.AlphaTestValue; Texture = texture; }
public Editor(Configuration configuration) { m_LauncherButton = new LauncherButton(); m_ToolbarButton = new ToolbarButton(); m_Position = new Rect(0.5f * Screen.width - 200.0f, 0.5f * Screen.height - 250.0f, 400.0f, 450.0f); m_NextButtonTexture = GameDatabase.Instance.GetTexture("KSEA/Historian/Historian_Button_Next", false); m_PreviousButtonTexture = GameDatabase.Instance.GetTexture("KSEA/Historian/Historian_Button_Previous", false); m_EnableLauncherButton = configuration.EnableLauncherButton; m_EnableToolberButton = configuration.EnableToolbarButton; if (m_EnableLauncherButton) { m_LauncherButton.OnTrue += Button_OnTrue; m_LauncherButton.OnFalse += Button_OnFalse; m_LauncherButton.Register(); } if (m_EnableToolberButton) { m_ToolbarButton.OnTrue += Button_OnTrue; m_ToolbarButton.OnFalse += Button_OnFalse; m_ToolbarButton.OnAlternateClick += Button_OnAlternateClick; m_ToolbarButton.Register(); } }
public void exportTexture(Texture export, string path) { /*static void ExportNormalmap () { var tex = Selection.activeObject as Texture2D; if (tex == null) { EditorUtility.DisplayDialog("No texture selected", "Please select a texture.", "Cancel"); return; } // Force the texture to be readable so that we can access its pixels var texPath = AssetDatabase.GetAssetPath(tex); var texImport : TextureImporter = AssetImporter.GetAtPath(texPath); if (!texImport.isReadable) { texImport.isReadable = true; AssetDatabase.ImportAsset(texPath, ImportAssetOptions.ForceUpdate); } var bytes = tex.EncodeToPNG(); var path = EditorUtility.SaveFilePanel("Save Texture", "", tex.name+"_normal.png", "png"); if (path != "") { System.IO.File.WriteAllBytes(path, bytes); AssetDatabase.RefreshDelayed(); // In case it was saved to the Assets folder } }*/ }
private void UpdateTexture() { var vessel = FlightGlobals.ActiveVessel; if (vessel != null) { List<string> flags = new List<string>(); foreach (var part in vessel.Parts) { flags.Add(part.flagURL); } // Find the flag with the highest occurrance in the entire vessel var url = flags.GroupBy(item => item).OrderByDescending(item => item.Count()).First().Key; if (string.IsNullOrEmpty(url)) { m_Texture = m_DefaultTexture; } else { m_Texture = GameDatabase.Instance.GetTexture(url, false); } } else { m_Texture = m_DefaultTexture; } }
public LaunchSite(string sName, string sAuthor, SiteType sType, Texture sLogo, Texture sIcon, string sDescription, string sDevice, float fOpenCost, float fCloseValue, string sOpenCloseState, float fRefLon, float fRefLat, float fRefAlt, float fLength, float fWidth, float fRefund, float fRecoveryFactor, float fRecoveryRange, GameObject gameObject, PSystemSetup.SpaceCenterFacility newFacility = null, string sFavourite = "No") { name = sName; author = sAuthor; type = sType; logo = sLogo; icon = sIcon; description = sDescription; category = sDevice; opencost = fOpenCost; closevalue = fCloseValue; openclosestate = sOpenCloseState; GameObject = gameObject; facility = newFacility; reflon = fRefLon; reflat = fRefLat; refalt = fRefAlt; sitelength = fLength; sitewidth = fWidth; launchrefund = fRefund; recoveryfactor = fRecoveryFactor; recoveryrange = fRecoveryRange; favouritesite = sFavourite; }
void OnEnable() { touchManager = target as TouchManager; var path = AssetDatabase.GetAssetPath( MonoScript.FromScriptableObject( this ) ); headerTexture = AssetDatabase.LoadAssetAtPath<Texture>( Path.GetDirectoryName( path ) + "/Images/TouchManagerHeader.png" ); }
public void Start() { consoleMsgs = new List<string> (); bioBtnIcon = loadImage("bioIcon");//flightscreen button. Opens window. bioCloseBack = loadImage("close"); StartCoroutine(updateConsole()); }
Resource ConvertTexture(UnityEngine.Texture texture) { string path = AssetDatabase.GetAssetPath(texture); if (texture is Texture2D) { var tex = (Texture2D)texture; Resource res = null; if (!_convertedAssets.TryGetValue(path, out res)) { CopyAsset(tex); res = new Texture(); res.resourcePath = path; _convertedAssets.Add(path, res); // TODO Import settings } return(res); } else { // TODO } return(null); }
public static tk2dSpriteCollectionData CreateFromTexture(Texture texture, tk2dSpriteCollectionSize size, Rect region, Vector2 anchor) { string[] names = new string[] { "Unnamed" }; Rect[] regions = new Rect[] { region }; Vector2[] anchors = new Vector2[] { anchor }; return CreateFromTexture(texture, size, names, regions, anchors); }
protected void PipeTextures() { RefreshTextureScript rts = this.GetComponent<RefreshTextureScript>(); if (rts != null) { this.source = rts.toReplace; } else { //grab original base texture. this is source. this.source = this.renderer.material.GetTexture("_MainTex"); } if ((this.source as RenderTexture) != null) { RenderTexture s = this.source as RenderTexture; //create new destination texture. this.destination = new RenderTexture(s.width,s.height,s.depth); } else { this.destination = new RenderTexture(source.width,source.height,24); } //assign destination texture to existing shader. if (rts != null) { rts.toReplace = this.destination; } else { this.renderer.material.SetTexture("_MainTex",this.destination); } }
public static tk2dSpriteCollectionData CreateFromTexture(Texture texture, SpriteCollectionSize size, string[] names, Rect[] regions, Vector2[] anchors) { GameObject go = new GameObject("SpriteCollection"); tk2dSpriteCollectionData sc = go.AddComponent<tk2dSpriteCollectionData>(); sc.Transient = true; sc.version = tk2dSpriteCollectionData.CURRENT_VERSION; sc.invOrthoSize = 1.0f / size.orthoSize; sc.halfTargetHeight = size.targetHeight * 0.5f; sc.premultipliedAlpha = false; sc.material = new Material(Shader.Find("tk2d/BlendVertexColor")); sc.material.mainTexture = texture; sc.materials = new Material[1] { sc.material }; sc.textures = new Texture[1] { texture }; float scale = 2.0f * size.orthoSize / size.targetHeight; // Generate geometry sc.spriteDefinitions = new tk2dSpriteDefinition[regions.Length]; for (int i = 0; i < regions.Length; ++i) { sc.spriteDefinitions[i] = CreateDefinitionForRegionInTexture(texture, scale, regions[i], anchors[i]); sc.spriteDefinitions[i].name = names[i]; } foreach (var def in sc.spriteDefinitions) def.material = sc.material; return sc; }
private void DrawEvent(Texture icon, string eventName, int index) { bool active = index == selectedEventIndex; Color prevColor = GUI.backgroundColor; GUI.backgroundColor = active ? new Color(.5f, .5f, 1, 1) : prevColor; Rect area = EditorGUILayout.BeginHorizontal(); if (EditorGUI.Toggle(area, active, GUI.skin.box) && !active) { SelectEvent(index); } //EditorGUILayout.LabelField(new GUIContent(icon), GUILayout.MaxWidth(itemSize)); EditorGUILayout.BeginVertical(GUILayout.Height(itemSize)); GUILayout.FlexibleSpace(); GUI.skin.label.wordWrap = true; EditorGUILayout.LabelField(new GUIContent(eventName, icon), GUI.skin.label, GUILayout.Height(itemSize)); GUILayout.FlexibleSpace(); EditorGUILayout.EndVertical(); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUI.backgroundColor = prevColor; }
public override void Read(Material source, Material def) { this.StopWatching(); UnityEngine.Texture texture = source.GetTexture(this.ParamName); this.Default = def.GetTexture(this.ParamName); this.SetTexture(texture); }
private ImageId ExportImage(UnityEngine.Texture texture) { ImageId id = GetImageId(_root, texture); if (id != null) { return(id); } var image = new Image(); if (ExportNames) { image.Name = texture.name; } _images.Add(texture as Texture2D); image.Uri = Uri.EscapeUriString(texture.name + ".png"); id = new ImageId { Id = _root.Images.Count, Root = _root }; _root.Images.Add(image); return(id); }
public static int AspectSelectionGrid(int selected, Texture[] textures, int approxSize, GUIStyle style, string emptyString, out bool doubleClick) { GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinHeight(10f) }; GUILayout.BeginVertical("box", options); int num = 0; doubleClick = false; if (textures.Length != 0) { float num2 = (EditorGUIUtility.currentViewWidth - 20f) / ((float) approxSize); int num3 = (int) Mathf.Ceil(((float) textures.Length) / num2); Rect aspectRect = GUILayoutUtility.GetAspectRect(num2 / ((float) num3)); Event current = Event.current; if (((current.type == EventType.MouseDown) && (current.clickCount == 2)) && aspectRect.Contains(current.mousePosition)) { doubleClick = true; current.Use(); } num = GUI.SelectionGrid(aspectRect, selected, textures, Mathf.RoundToInt(EditorGUIUtility.currentViewWidth - 20f) / approxSize, style); } else { GUILayout.Label(emptyString, new GUILayoutOption[0]); } GUILayout.EndVertical(); return num; }
public static Material FromUnity(Scene scene, UnityEngine.Material unity_material) { if (shadersProperties == null) { TextAsset properties = Resources.Load <TextAsset>(Constants.shaderDatabase); if (properties != null && properties.bytes.Length > 0) { shadersProperties = (Dictionary <int, string[]>)Module.Import.Binary.serializer.Deserialize(properties.bytes); } } if (shadersProperties != null) { // Create new material Material material = new Material(); // Save material options material.name = unity_material.name; material.shader = unity_material.shader.name; material.renderQueue = unity_material.renderQueue; material.hideFlags = unity_material.hideFlags; material.globalIlluminationFlags = unity_material.globalIlluminationFlags; material.keywords = unity_material.shaderKeywords; material.passes = new bool[unity_material.passCount]; // Save material enabled passes for (int i = 0; i < material.passes.Length; i++) { #if UNITY_5_6_OR_NEWER material.passes[i] = unity_material.GetShaderPassEnabled(unity_material.GetPassName(i)); #else material.passes[i] = true; #endif } // Save material properties // Range properties in Unity are f****d-up. It can be either int or float values, and their is no way to know wich one it is. // However, if we restore them using the wrong type, we get no errors but they are (obviously) ignored... // Therefore, we will save range as both int and float to be conservative. FromUnityMaterialProperties(unity_material, Shaders.PropertyType.RANGE, ref material.ints, (m, p) => m.GetInt(p)); FromUnityMaterialProperties(unity_material, Shaders.PropertyType.RANGE, ref material.floats, (m, p) => m.GetFloat(p)); FromUnityMaterialProperties(unity_material, Shaders.PropertyType.FLOAT, ref material.floats, (m, p) => m.GetFloat(p)); FromUnityMaterialProperties(unity_material, Shaders.PropertyType.VECTOR, ref material.vectors, (m, p) => m.GetVector(p)); FromUnityMaterialProperties(unity_material, Shaders.PropertyType.COLOR, ref material.colors, (m, p) => m.GetColor(p)); FromUnityMaterialProperties(unity_material, Shaders.PropertyType.TEXTURE, ref material.textures, (m, p) => { UnityEngine.Texture unity_tex = m.GetTexture(p); int index = (unity_tex != null && unity_tex is Texture2D ? scene.GetUnityTextureIndex((Texture2D)unity_tex) : -1); return(index >= 0 ? new TextureParams((uint)index, m.GetTextureOffset(p), m.GetTextureScale(p)) : null); }); return(material); } return(null); }
/*设置texAnimation图片*/ private void SetTexAnimaitionImage(string path, UITexture texAnimation) { UnityEngine.Texture tex = CrossObjectHelper.TryCastObject <UnityEngine.Texture>(ArkCrossEngine.ResourceSystem.GetSharedResource(path)); if (tex != null && texAnimation != null) { texAnimation.mainTexture = tex; } }
public VideoStreamTrack(string label, UnityEngine.Texture source) : this(label, source, CreateRenderTexture(source.width, source.height, WebRTC.GetSupportedRenderTextureFormat(SystemInfo.graphicsDeviceType)), source.width, source.height) { }
private TextureInfo ExportTextureInfo(UnityEngine.Texture texture) { var info = new TextureInfo(); info.Index = ExportTexture(texture); return(info); }
internal void SetTexture(string paramName, UnityEngine.Texture tex) { this.Skin.Materials[this.EditingMaterial].SetTexture(paramName, tex); if (paramName == "_EmissionMap" && tex != null) { this.Skin.Materials[this.EditingMaterial].EnableKeyword("_EMISSION"); } }
static public int set_wrapMode(IntPtr l) { UnityEngine.Texture o = (UnityEngine.Texture)checkSelf(l); UnityEngine.TextureWrapMode v; checkEnum(l, 2, out v); o.wrapMode = v; return(0); }
public void SetTextureForADC(UnityEngine.Texture inTex) { myMaterial.mainTexture = inTex; Globals.Assert(myMaterial.mainTexture != null); pixelsWide = (int)myMaterial.mainTexture.width; pixelsHigh = (int)myMaterial.mainTexture.height; }
private void calculateTokenRenderSize(dfMarkupToken token) { try { dfFont font = (dfFont)base.Font; int kerning = 0; char chr = '\0'; char item = '\0'; if ((token.TokenType == dfMarkupTokenType.Whitespace ? true : token.TokenType == dfMarkupTokenType.Text)) { int num = 0; while (num < token.Length) { item = token[num]; if (item != '\t') { dfFont.GlyphDefinition glyph = font.GetGlyph(item); if (glyph != null) { if (num > 0) { kerning = kerning + font.GetKerning(chr, item); kerning = kerning + base.CharacterSpacing; } kerning = kerning + glyph.xadvance; } } else { kerning = kerning + base.TabSize; } num++; chr = item; } } else if (token.TokenType == dfMarkupTokenType.StartTag && token.Matches("sprite")) { if (token.AttributeCount < 1) { throw new Exception("Missing sprite name in markup"); } UnityEngine.Texture texture = font.Texture; int lineHeight = font.LineHeight; string value = token.GetAttribute(0).Value.Value; dfAtlas.ItemInfo itemInfo = font.atlas[value]; if (itemInfo != null) { float single = itemInfo.region.width * (float)texture.width / (itemInfo.region.height * (float)texture.height); kerning = Mathf.CeilToInt((float)lineHeight * single); } } token.Height = base.Font.LineHeight; token.Width = kerning; } finally { } }
private static bool CreateButton(string label, Texture icon, float iconSize, GUIStyle buttonStyle) { return(GUILayout.Button( new GUIContent(label, icon), buttonStyle, GUILayout.Width(iconSize), GUILayout.Height(iconSize) )); }