You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
4.0 KiB
118 lines
4.0 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using AX.TrackRecord; |
|
using AX.MessageSystem; |
|
public class LoadJijie : MonoBehaviour { |
|
|
|
|
|
private TextMesh Nametext; |
|
private string Name; |
|
[HideInInspector] |
|
public GameObject LookText; |
|
private Color color; |
|
public int nameScaleFactor = 3; |
|
public float headName_y_Factor = 0.05f; |
|
private void Awake() |
|
{ |
|
Nametext = transform.Find("infos/Name").GetComponent<TextMesh>(); |
|
LookText = transform.Find("infos").gameObject; |
|
MessageDispatcher.AddListener("LoadJiJieSET", LoadJiJieSET); |
|
MessageDispatcher.AddListener("ScaleObjInfo", ScaleObjInfo); |
|
|
|
//int scales = (int)((GameObject.Find("Main Camera").GetComponent<MouseFollowRotation>().distance - |
|
// GameObject.Find("Main Camera").GetComponent<MouseFollowRotation>().minDistance) / |
|
// (GameObject.Find("Main Camera").GetComponent<MouseFollowRotation>().mSpeed / 10)); |
|
//if (gameObject.name.Contains("xiaofangche")) |
|
//{ |
|
// ScaleName(nameScaleFactor, headName_y_Factor, scales); |
|
//} |
|
//else |
|
//{ |
|
// ScaleName(nameScaleFactor, headName_y_Factor * 2, scales); |
|
//} |
|
} |
|
private void ScaleObjInfo(IMessage obj) |
|
{ |
|
//int scales = (int)obj.Data; |
|
//ScaleName(nameScaleFactor, headName_y_Factor, scales); |
|
} |
|
private float y; |
|
public void ScaleName(int nameScaleFactor, float headName_y_Factor, int scales) |
|
{ |
|
Nametext.fontSize |
|
= Nametext.fontSize + nameScaleFactor * scales; |
|
|
|
y = LookText.gameObject.transform.Find("Name").transform.localPosition.y + headName_y_Factor * scales; |
|
LookText.gameObject.transform.Find("Name").transform.localPosition |
|
= new Vector3(LookText.gameObject.transform.Find("Name").transform.localPosition.x, y, LookText.gameObject.transform.Find("Name").transform.localPosition.z); |
|
|
|
|
|
} |
|
public void LoadJiJieSET(IMessage mes) |
|
{ |
|
ObjAttribute oriObj = (ObjAttribute)mes.Data; |
|
if (oriObj.ObjName == gameObject.name) |
|
{ |
|
Jijie = oriObj.jijiequ; |
|
} |
|
} |
|
private void OnDestroy() |
|
{ |
|
MessageDispatcher.RemoveListener("LoadJiJieSET", LoadJiJieSET); |
|
MessageDispatcher.RemoveListener("ScaleObjInfo", ScaleObjInfo); |
|
} |
|
public void ControlSize() |
|
{ |
|
if (LookText.transform.localScale.x > 1) |
|
{ |
|
LookText.transform.localScale = new Vector3(1, LookText.transform.localScale.y, 1); |
|
} |
|
if (LookText.transform.localScale.z > 1) |
|
{ |
|
LookText.transform.localScale = new Vector3(1, LookText.transform.localScale.y, 1); |
|
} |
|
|
|
} |
|
|
|
private JiJieQu jijie; |
|
|
|
public JiJieQu Jijie |
|
{ |
|
set |
|
{ |
|
jijie = new JiJieQu(); |
|
jijie = value; |
|
color = jijie.color; |
|
Name = jijie.Name; |
|
Nametext.text = Name; |
|
this.gameObject.GetComponent<Renderer>().material.color = color; |
|
this.gameObject.transform.localScale = new Vector3(jijie.Width, gameObject.transform.localScale.y, jijie.Length); |
|
if (LookText.transform.localScale.x > 1) |
|
{ |
|
LookText.transform.localScale = new Vector3(1, LookText.transform.localScale.y, 1); |
|
} |
|
if (LookText.transform.localScale.z > 1) |
|
{ |
|
LookText.transform.localScale = new Vector3(1, LookText.transform.localScale.y, 1); |
|
} |
|
//if (LookText.transform.localScale.x > 1) |
|
//{ |
|
// LookText.transform.localScale = new Vector3(1, LookText.transform.localScale.y, 11); |
|
//} |
|
} |
|
get |
|
{ |
|
jijie = new JiJieQu(); |
|
jijie.Name = Name; |
|
jijie.color = color; |
|
jijie.Width = this.gameObject.transform.localScale.x; |
|
jijie.Length = this.gameObject.transform.localScale.z; |
|
return jijie; |
|
} |
|
} |
|
void LateUpdate() |
|
{ |
|
//LookText.transform.LookAt(Camera.main.transform); |
|
} |
|
}
|
|
|