private void CreateActor(GameObject model) { string fn = XXToolsEditorGlobal.DB_ACTOR_PATH + model.name + ".prefab"; if (XXToolsEdUtil.RelativeFileExist(fn)) { fn = AssetDatabase.GenerateUniqueAssetPath(fn); } GameObject go = PrefabUtility.CreatePrefab(fn, model); XXToolsEditorGlobal.DB.actorsPrefabs.Add(go); EditorUtility.SetDirty(XXToolsEditorGlobal.DB); AssetDatabase.SaveAssets(); Actor actor = go.AddComponent <Actor>(); // 扫描 skinnedMesh SkinnedMeshRenderer [] smrs = model.GetComponentsInChildren <SkinnedMeshRenderer>(); List <Actor.ActorComponent> acList = new List <Actor.ActorComponent>(); foreach (SkinnedMeshRenderer smr in smrs) { string[] strs = smr.name.Split('_'); string endStr = "_" + strs[strs.Length - 1]; Actor.ActorComponent ac = new Actor.ActorComponent(strs[strs.Length - 1], endStr, smr); acList.Add(ac); } actor.InitActor(actor.gameObject, acList); }
private void BasicInfo() { EditorGUILayout.BeginVertical(XXToolsEdGui.BoxStyle, GUILayout.Width(240)); //curr.name = EditorGUILayout.TextField("Prefabs Name", curr.name); GUILayout.Label(curr.name, XXToolsEdGui.Head3Style); GUILayout.Space(10); GUILayout.Label("Actor Comp", XXToolsEdGui.Head4Style); XXToolsEdGui.BeginScrollView(scroll[1], GUILayout.MaxHeight(200)); { for (int i = 0; i < curr.components.Count; i++) { Actor.ActorComponent ac = curr.components[i]; EditorGUILayout.BeginHorizontal(GUILayout.Width(DatabaseEditor.LeftPanelWidth - 20), GUILayout.ExpandWidth(false)); { if (XXToolsEdGui.ToggleButton(currAc == ac, ac.name, XXToolsEdGui.ButtonLeftStyle, GUILayout.Width(160), GUILayout.ExpandWidth(false))) { GUI.FocusControl(""); currAc = ac; } if (GUILayout.Button("X", XXToolsEdGui.ButtonRightStyle, GUILayout.Width(20))) { delAc = ac; } } EditorGUILayout.EndHorizontal(); } } XXToolsEdGui.EndScrollView(); EditorGUILayout.EndVertical(); }
public static void Show(Actor.ActorComponent ac) { MutiSelectWiz window = EditorWindow.GetWindow <MutiSelectWiz>(true, "Add AC", true); window.inited = false; window.ac = ac; }
public void ShowAlterCompSV(int i) { alterCompSV.gameObject.SetActive(true); Actor actor = Main.ins.currActorGo.GetComponent <Actor>(); List <Actor.ActorComponent> list = actor.GetComponents(); Actor.ActorComponent ac = list[Main.ins.currCompIdx]; InitAlterCompSV(ac); }
void ClickAlter(GameObject go) { int i = int.Parse(go.name); Actor actor = Main.ins.currActorGo.GetComponent <Actor>(); Actor.ActorComponent comp = actor.GetComp(Main.ins.currCompIdx); actor.gameObject.SetActive(false); comp.SwapMesh(i); actor.gameObject.SetActive(true); }
public void InitAlterCompSV(Actor.ActorComponent ac) { List <string> showList = ac.canSwapList; Transform parent = alterButton.transform.parent; for (int j = 1; j < parent.childCount; j++) { GameObject.Destroy(parent.GetChild(j).gameObject); } List <GameObject> buttonList; buttonList = new List <GameObject>(); alterButton.gameObject.SetActive(true); Vector3 initPos = alterButton.transform.localPosition; for (int i = 0; i < showList.Count; i++) { GameObject newButton = Instantiate <GameObject>(alterButton.gameObject); newButton.transform.SetParent(alterButton.transform.parent); newButton.name = i.ToString(); newButton.transform.localPosition = new Vector3(initPos.x, initPos.y - i * 40, initPos.z); newButton.transform.Find("Text").GetComponent <Text>().text = showList[i]; ClickListener.Get(newButton).onClick = ClickAlter; } Transform contentTs = alterButton.transform.parent; RectTransform rectTs = contentTs as RectTransform; Rect rect = rectTs.rect; rect.height = showList.Count * 40 + 10; //Debug.Log(rect.width); //rectTs.sizeDelta = new Vector2(rect.width, rect.height); alterButton.gameObject.SetActive(false); }