void OnGUI() { EditorGUILayout.BeginVertical(); { EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Original target nickname: " + toReplaceTargetModel.nickname); popupSelection = EditorGUILayout.Popup(popupSelection, data.getTargetNickNames()); newTargetModel = data.targets [popupSelection]; if (GUILayout.Button("Delete original & replace with: " + newTargetModel.nickname)) { doReplace(); } if (GUILayout.Button("Close Window")) { hide(); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); }
void doAddNewTarget() { SequencerTargetModel model = new SequencerTargetModel(); model.nickname = "target_" + UnityEngine.Random.Range(0, int.MaxValue).ToString(); sequencerData.targets.Add(model); }
override public void undo() { //music if (musicClipName != SoundManager.nullSoundName) { SoundManager.Get().playMusic(musicClipName, musicClipVolume); } //characters (visible, pos, attire, expression) int count = myPlayer.sequencerData.targets.Count; for (int i = 0; i < count; i++) { if (myPlayer.sequencerData.targets [i].target == null) { continue; } SequencerTargetModel model = myPlayer.sequencerData.targets [i]; VN_CharBase hasCharComp = model.target.GetComponent <VN_CharBase>(); model.target.transform.position = positions [i]; if (hasCharComp != null) { model.target.SetActive(visibilitys [i]); hasCharComp.setAttire(attires [i]); hasCharComp.setExpression(expressions [i], true); } } //future: vars }
public SequencerTargetModel clone() { SequencerTargetModel newTarget = new SequencerTargetModel(); newTarget.target = target; newTarget.nickname = nickname; newTarget.type = type; return newTarget; }
public SequencerTargetModel clone() { SequencerTargetModel newTarget = new SequencerTargetModel(); newTarget.target = target; newTarget.nickname = nickname; newTarget.type = type; return(newTarget); }
private void drawDefineTargets() { EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Define Targets"); if (GUILayout.Button("New Target")) { doAddNewTarget(); } } EditorGUILayout.EndHorizontal(); //spacer GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); scrollPosTargets = EditorGUILayout.BeginScrollView(scrollPosTargets); { if (sequencerData != null && sequencerData.targets != null) { EditorGUILayout.BeginVertical(); { SequencerTargetModel[] tempTargets = new SequencerTargetModel[sequencerData.targets.Count]; sequencerData.targets.CopyTo(tempTargets); List <SequencerTargetModel> targets = new List <SequencerTargetModel>(tempTargets); for (int i = 0; i < targets.Count; i++) { if (i % 2 == 0) { EditorGUILayout.BeginHorizontal(guiBGAltColorB); } else { EditorGUILayout.BeginHorizontal(); } { GUILayout.Label("target:"); targets [i].target = EditorGUILayout.ObjectField(targets [i].target, typeof(GameObject), true) as GameObject; GUILayout.Label("Nickname:"); targets [i].nickname = GUILayout.TextField(targets [i].nickname); if (GUILayout.Button("Delete this target")) { doDeleteTarget(targets [i].target); } } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndVertical(); } } EditorGUILayout.EndScrollView(); }
SequencerTargetModel checkTargetExistsOrCreate(string name, SequencerData data, string type) { SequencerTargetModel targetModel; targetModel = data.getTargetModel(name); if (targetModel == null || targetModel.nickname != name) { targetModel = new SequencerTargetModel(); targetModel.nickname = name; targetModel.type = type; data.targets.Add(targetModel); GameObject newTargetObj = new GameObject(name); newTargetObj.transform.parent = newTargetObj.transform.root; targetModel.target = newTargetObj; //character ( assume 2D character because we are comming in from Ren'py) if (allowCharacterStubCreation && targetModel.type == SequencerTargetTypes.character ) { newTargetObj.AddComponent<VN_Character>(); } else if ( targetModel.type == SequencerTargetTypes.positional ) { newTargetObj.name += "Pos"; } } return targetModel; }
private void drawDefineTargets() { //setup characters view if (currentSetupTarget != null) { target_is3d = GUILayout.Toggle(target_is3d, "3D character"); if (target_is3d) { target_addAnims = GUILayout.Toggle(target_addAnims, "Add Selected Animations"); } else { target_addAttires = GUILayout.Toggle(target_addAttires, "Add Selected as Attires"); target_addExpressions = GUILayout.Toggle(target_addExpressions, "Add Selected as Expressions ( backgrounds use this one)"); } if (currentSetupTarget.target == null) { GUILayout.BeginHorizontal(); { GUILayout.Label("Name of the resulting GameObject:"); target_name = EditorGUILayout.TextField(target_name); } GUILayout.EndHorizontal(); } if (GUILayout.Button("Create GameObject or Add Sprites/Animations to existing")) { //check if go exists, and if it has a VN_CharBase component //check to add which type //check & add selected stuff if matches type if (currentSetupTarget.target == null) { currentSetupTarget.target = new GameObject(target_name); currentSetupTarget.target.transform.parent = currentSetupTarget.target.transform.root; } if (currentSetupTarget.target.GetComponent< VN_CharBase>() == null) { if (target_is3d) currentSetupTarget.target.AddComponent<VN_3D_Character>(); else currentSetupTarget.target.AddComponent<VN_Character>(); } if (target_is3d) { currentSetupTarget.target.GetComponent<VN_3D_Character>(); if (target_addAnims) { Animation animComp = currentSetupTarget.target.AddComponent<Animation>(); foreach (object obj in Selection.objects) { if (obj is AnimationClip) { animComp.AddClip(obj as AnimationClip, (obj as AnimationClip).name); } } } } else { VN_Character char2d = currentSetupTarget.target.GetComponent<VN_Character>(); List<Sprite> spriteSelection = new List<Sprite>(); foreach (object obj in Selection.objects) { if (obj is Sprite) { spriteSelection.Add(obj as Sprite); } } List<GameObject> instantiatedSprites = new List<GameObject>(); if (spriteSelection != null) { foreach (Sprite aSprite in spriteSelection) { GameObject newSprite = new GameObject(aSprite.name); SpriteRenderer spriteRen = newSprite.AddComponent<SpriteRenderer>(); spriteRen.sprite = aSprite; newSprite.transform.parent = currentSetupTarget.target.transform; instantiatedSprites.Add(newSprite); } if (target_addAttires) char2d.attires = instantiatedSprites.ToArray(); if (target_addExpressions) char2d.expressions = instantiatedSprites.ToArray(); } } currentSetupTarget = null; } } //normal define targets view else { EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Define Targets"); if (GUILayout.Button("New Target")) doAddNewTarget(); } EditorGUILayout.EndHorizontal(); //spacer GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); scrollPosTargets = EditorGUILayout.BeginScrollView(scrollPosTargets); { if (sequencerData != null && sequencerData.targets != null) { EditorGUILayout.BeginVertical(); { SequencerTargetModel[] tempTargets = new SequencerTargetModel[sequencerData.targets.Count]; sequencerData.targets.CopyTo(tempTargets); List<SequencerTargetModel> targets = new List<SequencerTargetModel>(tempTargets); for (int i = 0; i < targets.Count; i++) { if (i % 2 == 0) EditorGUILayout.BeginHorizontal(guiBGAltColorB); else EditorGUILayout.BeginHorizontal(); { GUILayout.Label("type:"); targets [i].type = SequencerTargetTypes.targetTypes [EditorGUILayout.Popup(Array.IndexOf(SequencerTargetTypes.targetTypes, targets [i].type), SequencerTargetTypes.targetTypes)]; GUILayout.Label("target:"); targets [i].target = EditorGUILayout.ObjectField(targets [i].target, typeof(GameObject), true) as GameObject; GUILayout.Label("Nickname:"); GUILayout.Label(targets [i].nickname); if (targets [i].type == SequencerTargetTypes.character) { if (GUILayout.Button("Setup Character")) { currentSetupTarget = targets [i]; } } if (GUILayout.Button("Rename")) { doRenameTarget(targets [i]); } if (GUILayout.Button("Delete/Replace")) doDeleteTarget(targets [i]); } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndVertical(); } } EditorGUILayout.EndScrollView(); } }
void doRenameTarget(SequencerTargetModel toRenameTargetModel) { renameTargetWindowLive = (RenameTargetWindow)EditorWindow.GetWindow(typeof(RenameTargetWindow)); renameTargetWindowLive.toRenameTargetModel = toRenameTargetModel; renameTargetWindowLive.data = sequencerData; }
void doImportSequencerFile() { string[] splitFile = fileData.text.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); GameObject newDataHolder = new GameObject("sequencerDataHolderObject"); SequencerData data = newDataHolder.AddComponent<SequencerData>(); string currentType = ""; SequencerSectionModel lastSectionModel = null; for (int i=0; i < splitFile.Length; i++) { if (splitFile [i].Contains("TARGETS:")) { currentType = "targets"; continue; } else if (splitFile [i].Contains("VARIABLES:")) { currentType = "variables"; continue; } else if (splitFile [i].Contains("SECTIONS:")) { currentType = "sections"; continue; } string[] splitLine = splitFile [i].Split(new char[] {'╫'}); if (currentType == "targets") { SequencerTargetModel targetModel = new SequencerTargetModel(); targetModel.nickname = splitLine [0]; targetModel.type = splitLine [2]; GameObject goalTarget = GameObject.Find(splitLine [1]); if (goalTarget != null) targetModel.target = goalTarget; data.targets.Add(targetModel); } else if (currentType == "variables") { SequencerVariableModel variableModel = new SequencerVariableModel(); variableModel.name = splitLine [0]; variableModel.value = splitLine [1]; data.variables.Add(variableModel); } else if (currentType == "sections") { if (splitLine [0] == "section:") { lastSectionModel = new SequencerSectionModel(); lastSectionModel.commandList = new List<SequencerCommandBase>(); lastSectionModel.name = splitLine [1]; data.sections.Add(lastSectionModel); continue; } else { SequencerCommandBase command = ScriptableObject.CreateInstance(splitLine [0]) as SequencerCommandBase; command.init(lastSectionModel.name, data); command.initFromSequncerSerializedString(splitLine); lastSectionModel.commandList.Add(command); } } } Debug.LogWarning("Done, importing file"); }
//note this deletes all found with same target ( in general we dont want duplicate targets anyway) void doDeleteTarget(SequencerTargetModel targetModel) { //check if target is being used, if it is, then pop replace dialog window int numberOfRefrences = 0; //basically we do a rename to the same name, to check if there are any references, //I should probably fix this so it doesnt actually rename, just test by adding a flag to that function ? foreach (SequencerSectionModel sectionModel in sequencerData.sections) { foreach (SequencerCommandBase command in sectionModel.commandList) { bool wasUpdated = command.updateTargetReference(targetModel.nickname, targetModel.nickname); if (wasUpdated) numberOfRefrences += 1; } } if (numberOfRefrences > 0) { replaceTargetWindowLive = (ReplaceTargetWindow)EditorWindow.GetWindow(typeof(ReplaceTargetWindow)); replaceTargetWindowLive.toReplaceTargetModel = targetModel; replaceTargetWindowLive.data = sequencerData; } else sequencerData.targets.Remove(targetModel); }
void OnEnable() { if (dataHolderGO != null) { testForData(); } littleTextureForBG_A = new Texture2D(1, 1); littleTextureForBG_A.SetPixel(0, 0, new Color(0f, 1f, 1f, .15f)); littleTextureForBG_A.Apply(); littleTextureForBG_A.hideFlags = HideFlags.HideAndDontSave; guiBGAltColorA = new GUIStyle(); guiBGAltColorA.normal.background = littleTextureForBG_A; littleTextureForBG_B = new Texture2D(1, 1); littleTextureForBG_B.SetPixel(0, 0, new Color(1f, 0f, 1f, .15f)); littleTextureForBG_B.Apply(); littleTextureForBG_B.hideFlags = HideFlags.HideAndDontSave; guiBGAltColorB = new GUIStyle(); guiBGAltColorB.normal.background = littleTextureForBG_B; currentSetupTarget = null; }