void LocateMyCanvas(CinemachineBrain parent, bool createIfNotFound) { if (mCanvas == null || mCanvasParent != parent) { mCanvas = null; mRawImage = null; mViewport = null; mCanvasParent = parent; string canvasName = CanvasName; int numChildren = parent.transform.childCount; for (int i = 0; mCanvas == null && i < numChildren; ++i) { RectTransform child = parent.transform.GetChild(i) as RectTransform; if (child != null && child.name == canvasName) { mCanvas = child.gameObject; } } } if (mCanvas == null && createIfNotFound) { CreateCanvas(parent); } if (mCanvas != null && (mRawImage == null || mViewport == null)) { mViewport = mCanvas.GetComponentInChildren <RectTransform>(); mRawImage = mCanvas.GetComponentInChildren <UnityEngine.UI.RawImage>(); } }
// Use this for initialization void Start() { rawImage = GetComponent <RawImage>(); rectTransform = GetComponent <RectTransform>(); textureSize = rawImage.texture.width; }
static int _m_IsDestroyed(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.UI.RawImage __cl_gen_to_be_invoked = (UnityEngine.UI.RawImage)translator.FastGetCSObj(L, 1); bool isDestroyed = false; if (__cl_gen_to_be_invoked != null) { isDestroyed = __cl_gen_to_be_invoked.IsDestroyed(); } else { isDestroyed = true; } LuaAPI.lua_pushboolean(L, isDestroyed); return(1); } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
/*private void AddPostProcessing(GameObject cameraObject) * { #if POST_PROCESSING * PostProcessVolume volume = cameraObject.AddComponent<PostProcessVolume>(); * volume.isGlobal = true; * volume.profile = profile; * volume.weight = 1; * PostProcessLayer layer = cameraObject.AddComponent<PostProcessLayer>(); * layer.volumeTrigger = cameraObject.transform; * layer.volumeLayer = 1; * layer.Init(resources); #endif * }*/ public void CreateRenderTexture(Camera camera, CameraData cameraData, int id) { int screenWidth = Screen.width; // 1920 int screenHeight = Screen.height; // 1080 Debug.Log("Created camera with width and height of: " + screenWidth + " x " + screenHeight); camera.forceIntoRenderTexture = true; // Create UI! assign new texture GameObject uiObject = new GameObject(); uiObject.name = camera.gameObject.name; UnityEngine.UI.RawImage image = uiObject.AddComponent <UnityEngine.UI.RawImage>(); Canvas canvas = GameObject.FindObjectOfType <Canvas>(); if (canvas) { RectTransform parent = canvas.GetComponent <RectTransform>(); if (canvas.transform.Find("Cameras")) { parent = canvas.transform.Find("Cameras").GetComponent <RectTransform>(); } uiObject.transform.SetParent(parent); } uiObject.transform.localScale = new Vector3(1, 1, 1); cameraUIs.Add(id, uiObject); CreateRenderTextureTexture(id, cameraData, camera, image);//, textureWidth, textureHeight); }
void Start() { if (backgroundImage == null) { backgroundImage = GetComponent <UnityEngine.UI.RawImage>(); } }
void Start() { if (backgroundImage == null) { backgroundImage = GetComponent <UnityEngine.UI.RawImage>(); } kinectManager = KinectManager.Instance; sensorData = kinectManager != null?kinectManager.GetSensorData(sensorIndex) : null; if (sensorData != null) { // enable the color camera aligned depth frames sensorData.sensorInterface.EnableColorCameraDepthFrame(sensorData, true); // create the output texture and needed buffers depthImageTexture = KinectInterop.CreateRenderTexture(depthImageTexture, sensorData.colorImageWidth, sensorData.colorImageHeight); depthImageMaterial = new Material(Shader.Find("Kinect/DepthHistImageShader")); //int depthBufferLength = sensorData.colorImageWidth * sensorData.colorImageHeight >> 1; //depthImageBuffer = KinectInterop.CreateComputeBuffer(depthImageBuffer, depthBufferLength, sizeof(uint)); depthHistBuffer = KinectInterop.CreateComputeBuffer(depthHistBuffer, DepthSensorBase.MAX_DEPTH_DISTANCE_MM + 1, sizeof(int)); depthHistBufferData = new int[DepthSensorBase.MAX_DEPTH_DISTANCE_MM + 1]; equalHistBufferData = new int[DepthSensorBase.MAX_DEPTH_DISTANCE_MM + 1]; } }
protected void Start() { switch (m_UIType) { case UIType.Text: m_Text = this.GetComponent <UnityEngine.UI.Text>(); break; case UIType.Image: m_Image = this.GetComponent <UnityEngine.UI.Image>(); break; case UIType.RawImage: m_RawImage = this.GetComponent <UnityEngine.UI.RawImage>(); break; case UIType.Button: m_Button = this.GetComponent <UnityEngine.UI.Button>(); m_Button.onClick.AddListener(ButtonOnClick); break; case UIType.Toggle: m_Toggle = this.GetComponent <UnityEngine.UI.Toggle>(); m_Toggle.onValueChanged.AddListener(delegate { ToggleValueChanged(m_Toggle); }); break; case UIType.Dropdown: m_Dropdown = GetComponent <UnityEngine.UI.Dropdown>(); m_Dropdown.onValueChanged.AddListener(DropdownValueChanged); break; default: break; } }
protected override void Awake() { VideoPlayer = GO.GetComponent <VideoPlayer>(); Image = GO.GetComponent <UnityEngine.UI.RawImage>(); base.Awake(); VideoPlayer.source = VideoSource.VideoClip; VideoPlayer.playOnAwake = false; VideoPlayer.prepareCompleted += Prepared; }
void Start() { if (backgroundImage == null) { backgroundImage = GetComponent <UnityEngine.UI.RawImage>(); } kinectManager = KinectManager.Instance; sensorData = kinectManager != null?kinectManager.GetSensorData(sensorIndex) : null; }
// Use this for initialization public override void Start() { base.Start(); UnityEngine.UI.RawImage image = GetComponentInChildren <UnityEngine.UI.RawImage>(); if (image != null) { defaultMaterial = image.material; meshrenderer = null; } }
protected override void GetDependencies(System.Collections.Generic.Dictionary <long, UnityEngine.Object> dependencies, object obj) { base.GetDependencies(dependencies, obj); if (obj == null) { return; } UnityEngine.UI.RawImage o = (UnityEngine.UI.RawImage)obj; AddDependency(o.texture, dependencies); }
public override void ReadFrom(object obj) { base.ReadFrom(obj); if (obj == null) { return; } UnityEngine.UI.RawImage o = (UnityEngine.UI.RawImage)obj; texture = o.texture.GetMappedInstanceID(); uvRect = o.uvRect; }
private static void AddVariable(StoryInstance instance, string name, UnityEngine.GameObject control) { instance.SetVariable(name, control); UnityEngine.UI.Text text = control.GetComponent <UnityEngine.UI.Text>(); if (null != text) { instance.SetVariable(string.Format("{0}_Text", name), text); } UnityEngine.UI.Image image = control.GetComponent <UnityEngine.UI.Image>(); if (null != image) { instance.SetVariable(string.Format("{0}_Image", name), image); } UnityEngine.UI.RawImage rawImage = control.GetComponent <UnityEngine.UI.RawImage>(); if (null != rawImage) { instance.SetVariable(string.Format("{0}_RawImage", name), rawImage); } UnityEngine.UI.Button button = control.GetComponent <UnityEngine.UI.Button>(); if (null != button) { instance.SetVariable(string.Format("{0}_Button", name), button); } UnityEngine.UI.Dropdown dropdown = control.GetComponent <UnityEngine.UI.Dropdown>(); if (null != dropdown) { instance.SetVariable(string.Format("{0}_Dropdown", name), dropdown); } UnityEngine.UI.InputField inputField = control.GetComponent <UnityEngine.UI.InputField>(); if (null != inputField) { instance.SetVariable(string.Format("{0}_Input", name), inputField); } UnityEngine.UI.Slider slider = control.GetComponent <UnityEngine.UI.Slider>(); if (null != inputField) { instance.SetVariable(string.Format("{0}_Slider", name), slider); } UnityEngine.UI.Toggle toggle = control.GetComponent <UnityEngine.UI.Toggle>(); if (null != toggle) { instance.SetVariable(string.Format("{0}_Toggle", name), toggle); } UnityEngine.UI.ToggleGroup toggleGroup = control.GetComponent <UnityEngine.UI.ToggleGroup>(); if (null != toggleGroup) { instance.SetVariable(string.Format("{0}_ToggleGroup", name), toggleGroup); } UnityEngine.UI.Scrollbar scrollbar = control.GetComponent <UnityEngine.UI.Scrollbar>(); if (null != scrollbar) { instance.SetVariable(string.Format("{0}_Scrollbar", name), scrollbar); } }
protected void _Create(EleBaseRect parent, Texture t, Vector2 size, string name = "") { GameObject go = new GameObject("Texture_" + name); go.transform.SetParent(parent.GetContentRect(), false); this.rawImg = go.AddComponent <UnityEngine.UI.RawImage>(); this.rawImg.rectTransform.RTQ().TopLeftAnchorsPivot().ZeroOffsets(); this.rawImg.texture = t; }
public override object WriteTo(object obj, System.Collections.Generic.Dictionary <long, UnityEngine.Object> objects) { obj = base.WriteTo(obj, objects); if (obj == null) { return(null); } UnityEngine.UI.RawImage o = (UnityEngine.UI.RawImage)obj; o.texture = (UnityEngine.Texture)objects.Get(texture); o.uvRect = uvRect; return(o); }
static int _s_set_texture(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.UI.RawImage gen_to_be_invoked = (UnityEngine.UI.RawImage)translator.FastGetCSObj(L, 1); gen_to_be_invoked.texture = (UnityEngine.Texture)translator.GetObject(L, 2, typeof(UnityEngine.Texture)); } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(0); }
void Start() { if (backgroundImage == null) { backgroundImage = GetComponent <UnityEngine.UI.RawImage>(); } if (imageSize == Vector2.zero && backgroundImage != null && backgroundImage.texture != null) { imageSize = new Vector2Int(backgroundImage.texture.width, backgroundImage.texture.height); } }
static int _g_get_texture(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.UI.RawImage __cl_gen_to_be_invoked = (UnityEngine.UI.RawImage)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.texture); } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(1); }
static int _s_set_uvRect(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.UI.RawImage __cl_gen_to_be_invoked = (UnityEngine.UI.RawImage)translator.FastGetCSObj(L, 1); UnityEngine.Rect __cl_gen_value; translator.Get(L, 2, out __cl_gen_value); __cl_gen_to_be_invoked.uvRect = __cl_gen_value; } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(0); }
static int _m_SetRawImage_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 4 && translator.Assignable <UnityEngine.UI.RawImage>(L, 1) && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3) && (LuaAPI.lua_isnil(L, 4) || LuaAPI.lua_type(L, 4) == LuaTypes.LUA_TFUNCTION)) { UnityEngine.UI.RawImage _img = (UnityEngine.UI.RawImage)translator.GetObject(L, 1, typeof(UnityEngine.UI.RawImage)); string _file_path = LuaAPI.lua_tostring(L, 2); bool _is_auto_size = LuaAPI.lua_toboolean(L, 3); XLua.LuaFunction _func = (XLua.LuaFunction)translator.GetObject(L, 4, typeof(XLua.LuaFunction)); XLuaFramework.UIHelper.SetRawImage(_img, _file_path, _is_auto_size, _func); return(0); } if (gen_param_count == 3 && translator.Assignable <UnityEngine.UI.RawImage>(L, 1) && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3)) { UnityEngine.UI.RawImage _img = (UnityEngine.UI.RawImage)translator.GetObject(L, 1, typeof(UnityEngine.UI.RawImage)); string _file_path = LuaAPI.lua_tostring(L, 2); bool _is_auto_size = LuaAPI.lua_toboolean(L, 3); XLuaFramework.UIHelper.SetRawImage(_img, _file_path, _is_auto_size); return(0); } if (gen_param_count == 2 && translator.Assignable <UnityEngine.UI.RawImage>(L, 1) && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { UnityEngine.UI.RawImage _img = (UnityEngine.UI.RawImage)translator.GetObject(L, 1, typeof(UnityEngine.UI.RawImage)); string _file_path = LuaAPI.lua_tostring(L, 2); XLuaFramework.UIHelper.SetRawImage(_img, _file_path); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to XLuaFramework.UIHelper.SetRawImage!")); }
void Start() { if (Source != null) { if (OutputTexture == null) { OutputTexture = new Texture2D(Source.Width, Source.Height, TextureFormat.RGB24, false); } Source.OnCapturingTime += Process; } output = GetComponent <UnityEngine.UI.RawImage>(); }
static StackObject *get_uvRect_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.UI.RawImage instance_of_this_method = (UnityEngine.UI.RawImage) typeof(UnityEngine.UI.RawImage).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.uvRect; return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
static StackObject *SetNativeSize_5(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.UI.RawImage instance_of_this_method = (UnityEngine.UI.RawImage) typeof(UnityEngine.UI.RawImage).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.SetNativeSize(); return(__ret); }
public override void OnEnable() { // Watch for any file changes: Watch(); // Get the UnityUI image panel from the GO: UnityEngine.UI.RawImage img = GetComponent <UnityEngine.UI.RawImage>(); // Generate a new UI: HtmlUI = new FlatWorldUI("HtmlContent"); // Get dimensions: RectTransform dimensions = GetComponent <RectTransform>(); RectTransform = dimensions; Rect rect = dimensions.rect; // The virtual screen size: HtmlUI.SetDimensions((int)rect.width, (int)rect.height); // Load from HtmlFile or Src using the PowerUIManager.Navigate function: Navigate(document); // The UI should accept input: HtmlUI.AcceptInput = true; // Apply texture: img.texture = HtmlUI.Texture; // Add an updater which looks out for resizes right before the FWUI redraws: HtmlUI.OnUpdate = delegate(){ // Get the current rectangle: Rect currentRect = dimensions.rect; if (HtmlUI.SetDimensions((int)currentRect.width, (int)currentRect.height)) { // Resized! Get the texture again: img.texture = HtmlUI.Texture; } }; // Include the Unity UI when handling input: if (PowerUI.Input.UnityUICaster == null) { // Get the caster: PowerUI.Input.UnityUICaster = img.canvas.GetComponent <UnityEngine.UI.GraphicRaycaster>(); } }
/// <summary> /// Write the specified value using the writer. /// </summary> /// <param name="value">Value.</param> /// <param name="writer">Writer.</param> public override void Write(object value, ISaveGameWriter writer) { UnityEngine.UI.RawImage rawImage = (UnityEngine.UI.RawImage)value; writer.WriteProperty("texture", rawImage.texture); writer.WriteProperty("uvRect", rawImage.uvRect); writer.WriteProperty("maskable", rawImage.maskable); writer.WriteProperty("color", rawImage.color); writer.WriteProperty("raycastTarget", rawImage.raycastTarget); writer.WriteProperty("material", rawImage.material); writer.WriteProperty("useGUILayout", rawImage.useGUILayout); writer.WriteProperty("enabled", rawImage.enabled); writer.WriteProperty("tag", rawImage.tag); writer.WriteProperty("name", rawImage.name); writer.WriteProperty("hideFlags", rawImage.hideFlags); }
void Start() { m_gamepad = GetComponent<HFTGamepad>(); m_renderer = GetComponent<Renderer>(); m_position = transform.localPosition; m_text = transform.FindChild("NameUI/Name").gameObject.GetComponent<UnityEngine.UI.Text>(); m_rawImage = transform.FindChild("NameUI/NameBackground").gameObject.GetComponent<UnityEngine.UI.RawImage>(); m_rawImage.material = (Material)Instantiate(m_rawImage.material); m_gamepad.OnNameChange += ChangeName; SetName(m_gamepad.Name); SetColor(m_gamepad.Color); }
//// depth-camera aligned frames //private ulong lastDepthCamColorFrameTime = 0; void Start() { if (backgroundImage == null) { backgroundImage = GetComponent <UnityEngine.UI.RawImage>(); } kinectManager = KinectManager.Instance; sensorData = kinectManager != null?kinectManager.GetSensorData(sensorIndex) : null; if (sensorData != null) { // enable the depth camera aligned color frames sensorData.sensorInterface.EnableDepthCameraColorFrame(sensorData, true); } }
// updates the background parameters private void UpdateBackgroundParams() { screenW = Screen.width; screenH = Screen.height; //Debug.Log("UpdateBackgroundParams() - scrW: " + screenW + ", scrH: " + screenH); KinectManager kinectManager = KinectManager.Instance; if (kinectManager && kinectManager.IsInitialized()) { // determine the target screen aspect ratio float screenAspectRatio = targetAspectRatio != Vector2.zero ? (targetAspectRatio.x / targetAspectRatio.y) : ((float)Screen.width / (float)Screen.height); float fFactorDW = (float)kinectManager.GetColorImageWidth(sensorIndex) / (float)kinectManager.GetColorImageHeight(sensorIndex) - //(float)kinectManager.GetColorImageHeight() / (float)kinectManager.GetColorImageWidth(); screenAspectRatio; float fDeltaWidth = (float)Screen.height * fFactorDW; float dOffsetX = -fDeltaWidth / 2f; float fFactorSW = (float)kinectManager.GetColorImageWidth(sensorIndex) / (float)kinectManager.GetColorImageHeight(sensorIndex); float fScreenWidth = (float)Screen.height * fFactorSW; float fAbsOffsetX = fDeltaWidth / 2f; pixelInsetRect = new Rect(dOffsetX, 0, fDeltaWidth, 0); backgroundRect = new Rect(dOffsetX, 0, fScreenWidth, Screen.height); inScreenRect = new Rect(fAbsOffsetX, 0, fScreenWidth - fDeltaWidth, Screen.height); shaderUvRect = new Rect(fAbsOffsetX / fScreenWidth, 0, (fScreenWidth - fDeltaWidth) / fScreenWidth, 1); //GUITexture guiTexture = GetComponent<GUITexture>(); //if(guiTexture) //{ // guiTexture.pixelInset = pixelInsetRect; //} UnityEngine.UI.RawImage rawImage = GetComponent <UnityEngine.UI.RawImage>(); if (rawImage) { rawImage.uvRect = shaderUvRect; } isInitialized = true; } }
public override void OnEnter() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go!=null) { _texture = _go.GetComponent<UnityEngine.UI.RawImage>(); } if (resetOnExit.Value) { _originalTexture = _texture.texture; } DoSetValue(); Finish(); }
static StackObject *set_texture_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Texture @value = (UnityEngine.Texture) typeof(UnityEngine.Texture).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.UI.RawImage instance_of_this_method = (UnityEngine.UI.RawImage) typeof(UnityEngine.UI.RawImage).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.texture = value; return(__ret); }
public LabelView(ref LabelCreateOptionsInterop createOptions, Canvas unityCanvas, List <Texture> iconTexturePages) { if (createOptions.HasTextComponent) { var newTextGameObject = GameObject.Instantiate(UnityEngine.Resources.Load <GameObject>(LabelTextPrefabPath)); var createOptionsText = Marshal.PtrToStringAnsi(createOptions.Text); newTextGameObject.name = createOptionsText; m_textComponent = newTextGameObject.GetComponent <UnityEngine.UI.Text>(); m_textComponent.fontSize = createOptions.BaseFontSize; m_textComponent.text = createOptionsText; m_textComponent.transform.SetParent(unityCanvas.transform, false); m_textComponent.transform.SetAsFirstSibling(); float fontScaleFactor = (float)createOptions.FontScale / unityCanvas.scaleFactor; m_textComponent.transform.localScale = new Vector3(fontScaleFactor, fontScaleFactor, fontScaleFactor); var newOutline = newTextGameObject.GetComponent <UnityEngine.UI.Outline>(); if (newOutline != null) { newOutline.effectColor = createOptions.HaloColor.ToColor(); } } if (createOptions.HasIconComponent) { var newIconGameObject = GameObject.Instantiate(UnityEngine.Resources.Load <GameObject>(LabelIconPrefabPath)); newIconGameObject.name = createOptions.Text + " - Icon"; m_iconComponent = newIconGameObject.GetComponent <UnityEngine.UI.RawImage>(); m_iconComponent.transform.SetParent(unityCanvas.transform, false); m_iconComponent.transform.SetAsFirstSibling(); m_iconComponent.texture = iconTexturePages[createOptions.iconTexturePage]; var uvScale = new Vector2(1.0f / 65536.0f, 1.0f / 65536.0f); // UV Scaling done on Native-side when texture is loaded, corrected here. m_iconComponent.uvRect = new Rect((float)createOptions.iconU0 * uvScale.x, (float)createOptions.iconV1 * uvScale.y, (float)createOptions.iconU1 * uvScale.x - (float)createOptions.iconU0 * uvScale.x, (float)createOptions.iconV0 * uvScale.y - (float)createOptions.iconV1 * uvScale.y); m_iconComponent.rectTransform.sizeDelta = new Vector2((float)createOptions.iconWidth, (float)createOptions.iconHeight); float iconScaleFactor = 1.0f / unityCanvas.scaleFactor; m_iconComponent.transform.localScale = new Vector3(iconScaleFactor, iconScaleFactor, iconScaleFactor); } }
void Start() { m_gamepad = GetComponent<HFTGamepad>(); m_renderer = GetComponent<Renderer>(); m_position = transform.localPosition; m_text = transform.FindChild("NameUI/Name").gameObject.GetComponent<UnityEngine.UI.Text>(); m_rawImage = transform.FindChild("NameUI/NameBackground").gameObject.GetComponent<UnityEngine.UI.RawImage>(); m_rawImage.material = (Material)Instantiate(m_rawImage.material); m_gamepad.OnNameChange += ChangeName; SetName(m_gamepad.Name); SetColor(m_gamepad.Color); m_playerRigidbody = GetComponent<Rigidbody>(); m_impulseParticles = m_impulseParticleEffectHolder.GetComponent<ParticleSystem>(); m_impulseParticles.startColor = m_gamepad.Color; m_playerLight = GetComponentInChildren<Light>(); m_playerLight.color = m_gamepad.Color; m_gameManager = FindObjectOfType<GameManager>(); }
void Start() { m_gamepad = GetComponent<HFTGamepad>(); m_renderer = GetComponent<Renderer>(); m_position = transform.localPosition; m_text = transform.FindChild("NameUI/Name").gameObject.GetComponent<UnityEngine.UI.Text>(); m_rawImage = transform.FindChild("NameUI/NameBackground").gameObject.GetComponent<UnityEngine.UI.RawImage>(); m_rawImage.material = (Material)Instantiate(m_rawImage.material); // Notify us if the name changes. m_gamepad.OnNameChange += ChangeName; // Delete ourselves if disconnected m_gamepad.OnDisconnect += Remove; SetName(m_gamepad.Name); SetColor(m_gamepad.Color); }