private static void AddRefPoints() { PEBlockAlign align = Selection.activeGameObject.GetComponent <PEBlockAlign>(); if (align == null) { Selection.activeGameObject.AddComponent <PEBlockAlign>(); } //处理特殊 string name = Selection.activeGameObject.name; int index = Selection.activeGameObject.name.IndexOf("(Clone)"); if (index > 0) { name = name.Substring(0, index); } BlockData data = PBDataBaseManager.Instance.GetBlockWithPrefabName(name); if (data.type == "wire") { Transform head = Selection.activeTransform.Find("head_2"); if (head.GetComponent <PEBlockAlign>() == null) { head.gameObject.AddComponent <PEBlockAlign>(); } } }
private static void RemoveRefPoints() { PEBlockAlign align = Selection.activeGameObject.GetComponent <PEBlockAlign>(); if (align != null) { align.ClearRefPoints(); Component.DestroyImmediate(align); } }
void OnEnable() { bool isInProject = EditorUtility.IsPersistent(this.target); if (!isInProject) { blockAlign = this.target as PEBlockAlign; blockAlign.ShowRefPoints(); } blockAlign = (PEBlockAlign)target; }
public override void OnInspectorGUI() { PEBlockAlign blockAlign = target as PEBlockAlign; if (GUILayout.Button("Reset")) { blockAlign.transform.position = Vector3.zero; blockAlign.transform.rotation = Quaternion.identity; blockAlign.ClearRefPoints(); blockAlign.ShowRefPoints(); } if (GUILayout.Button("Hide")) { blockAlign.HideRefPoints(); } if (GUILayout.Button("Show")) { blockAlign.ShowRefPoints(); } }
private void Rotate(Vector3 axi) { PEBlockAlign example = (PEBlockAlign)target; example.transform.Rotate(axi, 90, Space.Self); }
public void Init(PEBlockAlign blockAlign, RefPointType pointType) { this.blockAlign = blockAlign; refPointType = pointType; }