private void ModifyInclusions() { List <GameObject> listGameObjectFxToInclude = new List <GameObject>(); List <GameObject> listGameObjectFxToDeinclude = new List <GameObject>(); for (int i = 0; i < listCaronteFx_.Count; i++) { bool wasIncluded = listCaronteFx_[i].Third; bool hasToBeIncluded = arrEffectsToInclude[i]; if (wasIncluded != hasToBeIncluded) { Caronte_Fx fx = listCaronteFx_[i].First; if (hasToBeIncluded) { listGameObjectFxToInclude.Add(fx.gameObject); } else { listGameObjectFxToDeinclude.Add(fx.gameObject); } } } //Controller.DettachCaronteFxGameObjects(listGameObjectFxToDeinclude); Controller.AddCaronteFxGameObjects(listGameObjectFxToInclude); }
private void ModifyInclusions() { List <GameObject> listGameObjectFxToInclude = new List <GameObject>(); List <GameObject> listGameObjectFxToDeinclude = new List <GameObject>(); for (int i = 0; i < listCaronteFx_.Count; i++) { bool wasIncluded = listCaronteFx_[i].Third; bool cannotBeAdded = listCaronteFx_[i].Fourth; bool hasToBeIncluded = arrEffectsToInclude[i]; if (wasIncluded != hasToBeIncluded) { Caronte_Fx fx = listCaronteFx_[i].First; if (hasToBeIncluded && !cannotBeAdded) { listGameObjectFxToInclude.Add(fx.gameObject); } else { listGameObjectFxToDeinclude.Add(fx.gameObject); } } } if (listGameObjectFxToDeinclude.Count > 0 || listGameObjectFxToInclude.Count > 0) { cnManager_.ModifyEffectsIncluded(listGameObjectFxToDeinclude, listGameObjectFxToInclude); } }
//---------------------------------------------------------------------------------- public CNEffectEditor(CNGroup data, CommandNodeEditorState state) : base(data, state) { fxData_ = cnManager.FxData; effectData_ = fxData_.effect; selectedScopeIdx_ = (int)Data.CaronteFX_scope; }
//----------------------------------------------------------------------------------- public void Init(Caronte_Fx fxData) { fxData_ = fxData; tableVisibilityInterval_.Clear(); isChangeToReplayingDone_ = false; frameNumber_ = 0; nCorpuscles_ = 0; }
void OnGUI() { Rect effectsArea = new Rect(5, 5, width_ - 10, (height_ - 10) * 0.9f); GUILayout.BeginArea(effectsArea, GUI.skin.box); EditorGUILayout.BeginHorizontal(); { GUIStyle styleTitle = new GUIStyle(GUI.skin.label); styleTitle.fontStyle = FontStyle.Bold; GUILayout.Label("Child/Brother includible FXs:", styleTitle); } EditorGUILayout.EndHorizontal(); CRGUIUtils.Splitter(); EditorGUILayout.Space(); scrollPos_ = GUILayout.BeginScrollView(scrollPos_); { for (int i = 0; i < listCaronteFx_.Count; i++) { Caronte_Fx fx = listCaronteFx_[i].First; if (fx != Controller.FxData) { GUILayout.BeginHorizontal(); { string name = fx.name; arrEffectsToInclude[i] = EditorGUILayout.ToggleLeft(name, arrEffectsToInclude[i]); } GUILayout.EndHorizontal(); } } } GUILayout.EndScrollView(); GUILayout.EndArea(); Rect buttonsArea = new Rect(effectsArea.xMin, effectsArea.yMax, width_ - 10, (height_ - 10) * 0.1f); GUILayout.BeginArea(buttonsArea); { EditorGUILayout.Space(); GUILayout.BeginHorizontal(); { if (GUILayout.Button("Ok")) { Close(); ModifyInclusions(); } if (GUILayout.Button("Cancel")) { Close(); } } GUILayout.EndHorizontal(); } GUILayout.EndArea(); }
public static void GetCaronteFxsRelations(Caronte_Fx caronteFx, out List <Tuple2 <Caronte_Fx, int> > listCaronteFx) { listCaronteFx = new List <Tuple2 <Caronte_Fx, int> >(); GameObject go = caronteFx.gameObject; if (go.IsInScene()) { GameObject[] arrChild = CarEditorUtils.GetAllGameObjectsInScene(); AddRelations(go, arrChild, listCaronteFx); } }
public static void AddRelations(GameObject parentFx, GameObject[] arrGameObject, List <Tuple2 <Caronte_Fx, int> > listCaronteFx) { for (int i = 0; i < arrGameObject.Length; i++) { GameObject go = arrGameObject[i]; Caronte_Fx fxChild = go.GetComponent <Caronte_Fx>(); if (fxChild != null) { int depth = go.GetFxHierachyDepthFrom(parentFx); listCaronteFx.Add(Tuple2.New(fxChild, depth)); } } }
public override void OnInspectorGUI() { Caronte_Fx fxData = target as Caronte_Fx; EditorGUILayout.Space(); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Open in CaronteFX Editor", GUILayout.Height(30f))) { CRManagerEditor window = (CRManagerEditor)CRManagerEditor.Init(); window.Controller.SetFxDataActive(fxData); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); }
/// <summary> /// Builds a list with all the scene fx and their status(included/not included) /// </summary> void BuildEffectList() { List <Tuple2 <Caronte_Fx, int> > listCaronteFx; CREditorUtils.GetCaronteFxsRelations(Controller.FxData, out listCaronteFx); for (int i = 0; i < listCaronteFx.Count; i++) { Caronte_Fx fx = listCaronteFx[i].First; int depth = listCaronteFx[i].Second; bool alreadyAdded = Controller.IsEffectIncluded(fx); listCaronteFx_.Add(Tuple3.New(fx, depth, alreadyAdded)); } arrEffectsToInclude = new bool[listCaronteFx_.Count]; for (int i = 0; i < arrEffectsToInclude.Length; i++) { arrEffectsToInclude[i] = listCaronteFx_[i].Third; } }
/// <summary> /// Return a list with the relative fx and depth /// </summary> /// <param name="caronteFx"></param> /// <param name="listCaronteFx"></param> public static void GetCaronteFxsRelations(Caronte_Fx caronteFx, out List <Tuple2 <Caronte_Fx, int> > listCaronteFx) { listCaronteFx = new List <Tuple2 <Caronte_Fx, int> >(); GameObject go = caronteFx.gameObject; if (go.IsInScene()) { Transform searchRoot = go.transform.parent; if (searchRoot != null) { GameObject[] arrChild = GetAllChildObjects(searchRoot.gameObject, true); AddRelations(go, arrChild, listCaronteFx); } else { GameObject[] arrChild = GetAllGameObjectsInScene(); AddRelations(go, arrChild, listCaronteFx); } } }
/// <summary> /// Builds a list with all the scene fx and their status(included/not included) /// </summary> void BuildEffectList() { List <Tuple2 <Caronte_Fx, int> > listCaronteFx; CarDataUtils.GetCaronteFxsRelations(cnManager_.FxData, out listCaronteFx); for (int i = 0; i < listCaronteFx.Count; i++) { Caronte_Fx fx = listCaronteFx[i].First; int depth = listCaronteFx[i].Second; bool alreadyAdded = cnManager_.IsEffectIncluded(fx); bool wouldProduceInfiniteRecursion = cnManager_.RootNodeAlreadyContainedInNode(fx); listCaronteFx_.Add(Tuple4.New(fx, depth, alreadyAdded, wouldProduceInfiniteRecursion)); } arrEffectsToInclude = new BitArray(listCaronteFx_.Count); for (int i = 0; i < arrEffectsToInclude.Length; i++) { arrEffectsToInclude[i] = listCaronteFx_[i].Third; } }
public void Init(Caronte_Fx fxData) { fxData_ = fxData; }
public static void UpdateFxDataVersionIfNeeded(Caronte_Fx fxData) { GameObject dataHolder = fxData.GetDataGameObject(); if (fxData.DataVersion < 1) { CNBody[] arrBodyNode = dataHolder.GetComponents <CNBody>(); foreach (CNBody bodyNode in arrBodyNode) { bodyNode.OmegaStart_inDegSeg *= Mathf.Rad2Deg; EditorUtility.SetDirty(bodyNode); } fxData.DataVersion = 1; EditorUtility.SetDirty(fxData); CarDebug.Log("Updated " + fxData.name + " definitions to version 1."); } if (fxData.DataVersion < 2) { CNJointGroups[] arrJgGroups = dataHolder.GetComponents <CNJointGroups>(); foreach (CNJointGroups jgGroups in arrJgGroups) { jgGroups.ContactAngleMaxInDegrees *= Mathf.Rad2Deg; if (jgGroups.ContactAngleMaxInDegrees > 180f || jgGroups.ContactAngleMaxInDegrees < 0f) { jgGroups.ContactAngleMaxInDegrees -= (jgGroups.ContactAngleMaxInDegrees % 180f) * 180f; EditorUtility.SetDirty(jgGroups); } } fxData.DataVersion = 2; EditorUtility.SetDirty(fxData); CarDebug.Log("Updated " + fxData.name + " definitions to version 2."); } if (fxData.DataVersion < 3) { CNSoftbody[] arrSoftbodyNode = dataHolder.GetComponents <CNSoftbody>(); foreach (CNSoftbody sbNode in arrSoftbodyNode) { sbNode.LengthStiffness = Mathf.Clamp(sbNode.LengthStiffness, 0f, 30f); EditorUtility.SetDirty(sbNode); } fxData.DataVersion = 3; EditorUtility.SetDirty(fxData); CarDebug.Log("Updated " + fxData.name + " definitions to version 3."); } if (fxData.DataVersion < 4) { CNFracture[] arrFractureNode = dataHolder.GetComponents <CNFracture>(); foreach (CNFracture frNode in arrFractureNode) { if (frNode.ChopGeometry != null) { frNode.FieldSteeringGeometry.GameObjects.Add(frNode.ChopGeometry); EditorUtility.SetDirty(frNode); } if (frNode.CropGeometry != null) { frNode.FieldRestrictionGeometry.GameObjects.Add(frNode.CropGeometry); EditorUtility.SetDirty(frNode); } } fxData.DataVersion = 4; EditorUtility.SetDirty(fxData); CarDebug.Log("Updated " + fxData.name + " definitions to version 4."); } if (fxData.DataVersion < 5) { CNServos[] arrServos = dataHolder.GetComponents <CNServos>(); foreach (CNServos svNode in arrServos) { svNode.TargetExternal_LOCAL_NEW = new CarVector3Curve(svNode.TargetExternal_LOCAL, fxData.effect.totalTime_); EditorUtility.SetDirty(svNode); } fxData.DataVersion = 5; EditorUtility.SetDirty(fxData); CarDebug.Log("Updated " + fxData.name + " definitions to version 5."); } }
private void OnEnable() { fxData_ = (Caronte_Fx)target; LoadCaronteIcon(); }
void OnGUI() { Rect effectsArea = new Rect(5, 5, width_ - 10, (height_ - 10) * 0.9f); GUILayout.BeginArea(effectsArea, GUI.skin.box); EditorGUILayout.BeginHorizontal(); { GUIStyle styleTitle = new GUIStyle(GUI.skin.label); styleTitle.fontStyle = FontStyle.Bold; GUILayout.Label("Scene FXs:", styleTitle); } EditorGUILayout.EndHorizontal(); CarGUIUtils.Splitter(); EditorGUILayout.Space(); scrollPos_ = GUILayout.BeginScrollView(scrollPos_); { for (int i = 0; i < listCaronteFx_.Count; i++) { Caronte_Fx fx = listCaronteFx_[i].First; bool cannotBeAdded = listCaronteFx_[i].Fourth; if (fx != cnManager_.FxData) { GUILayout.BeginHorizontal(); { string name = fx.name; if (cannotBeAdded) { name += " - (Recursive inclusion detected)"; } EditorGUI.BeginDisabledGroup(cannotBeAdded); arrEffectsToInclude[i] = EditorGUILayout.ToggleLeft(name, arrEffectsToInclude[i]); EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); } } } GUILayout.EndScrollView(); GUILayout.EndArea(); Rect buttonsArea = new Rect(effectsArea.xMin, effectsArea.yMax, width_ - 10, (height_ - 10) * 0.1f); GUILayout.BeginArea(buttonsArea); { EditorGUILayout.Space(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Ok", GUILayout.Width(165f))) { Close(); ModifyInclusions(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel", GUILayout.Width(165f))) { Close(); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); } GUILayout.EndArea(); }