public static void Init() { SaveWindowPA window = (SaveWindowPA)EditorWindow.GetWindow(typeof(SaveWindowPA)); _scenarioHandler = new NewtonsoftScenarioHandler(); int x = (Screen.currentResolution.width - SaveWindowPA.WindowWidth) / 2; int y = (Screen.currentResolution.height - SaveWindowPA.WindowHeight) / 2; window.position = new Rect(x, y, SaveWindowPA.WindowWidth, SaveWindowPA.WindowHeight); window.Show(); }
public override void OnInspectorGUI() { if (GUILayout.Button("Spawn (PlayMode)")) { ParticleAttractor.TestSpawn(); } GUILayout.BeginVertical("HelpBox"); EditorGUILayout.LabelField("Particle Management", EditorStyles.boldLabel); ParticleAttractor.SpawnMode = (ParticleAttractor.ParticleSpawnMode)EditorGUILayout.EnumPopup("Spawn Mode: ", ParticleAttractor.SpawnMode); ParticleAttractor.IsDrawEnable = EditorGUILayout.Toggle("Draw Line: ", ParticleAttractor.IsDrawEnable); if (ParticleAttractor.IsDrawEnable) { if (GUILayout.Button("Assign main nodes")) { ParticleAttractor.Points[0] = ParticleAttractor.SourceTransform.position; ParticleAttractor.Points[ParticleAttractor.Points.Count - 1] = ParticleAttractor.DestinationTransform.position; } } GUILayout.EndVertical(); GUILayout.BeginVertical("HelpBox"); EditorGUILayout.LabelField("Component Settings", EditorStyles.boldLabel); ParticleAttractor.SourceTransform = (Transform)EditorGUILayout.ObjectField("Source Transform", ParticleAttractor.SourceTransform, typeof(Transform), true); ParticleAttractor.DestinationTransform = (Transform)EditorGUILayout.ObjectField("Destination Transform", ParticleAttractor.DestinationTransform, typeof(Transform), true); ParticleAttractor.RenderCanvas = (Canvas)EditorGUILayout.ObjectField("RenderCanvas", ParticleAttractor.RenderCanvas, typeof(Canvas), true); GUILayout.EndVertical(); GUILayout.BeginVertical("HelpBox"); EditorGUILayout.LabelField("Particles Settings", EditorStyles.boldLabel); ParticleAttractor.SpawnAmount = EditorGUILayout.IntField("Spawn Amount", ParticleAttractor.SpawnAmount); ParticleAttractor.SpawnRange = EditorGUILayout.FloatField("Spawn Position Range", ParticleAttractor.SpawnRange); ParticleAttractor.DurationRandomRange = EditorGUILayout.FloatField("Duration Random (%)", ParticleAttractor.DurationRandomRange); ParticleAttractor.SpawnImage = (Sprite)EditorGUILayout.ObjectField("Sprite", ParticleAttractor.SpawnImage, typeof(Sprite), true); GUILayout.EndVertical(); if (_scenarioInfo == null) { InitScenarioList(); } _scenarioList.DoLayoutList(); _scenarioInfo = typeof(ParticleAttractor).GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).Where(p => p.IsDefined(typeof(ParticleScenario), true)).ToList(); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Save")) { SaveWindowPA.SetScenarioData(ParticleAttractor.ScenarioList); SaveWindowPA.Init(); } if (GUILayout.Button("Load")) { string path = EditorUtility.OpenFilePanel("Load Scenario", "ParticleAttractorScenarioData", "*.*"); string[] filteredPath = path.Split('/'); IScenarioHandler scenarioHandler = new NewtonsoftScenarioHandler(); ParticleAttractor.ScenarioList = scenarioHandler.Load <List <ScenarioAction> >(filteredPath.Last()); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); base.OnInspectorGUI(); }