public override void OnInspectorGUI() { PrefabShooter shooter = target as PrefabShooter; m_obstacleLayers.Enabled = shooter.m_checkForObstacles; m_editHelp.EditProperties(shooter); }
public void ApplyTurret() { Aimer aimer = m_baseObject.AddComponent <Aimer>(); aimer.m_gunObject = m_gunBarrelObject; if (m_swivel) { aimer.m_optionalSwivel = m_swivelObject; } if (m_projectileHasGravity) { aimer.m_projectileType = Aimer.ProjectilePredictionType.Parabolic; } else { aimer.m_projectileType = Aimer.ProjectilePredictionType.Linear; } aimer.m_targetType = m_targetType; if (m_hasLimits) { m_baseObject.AddComponent <Limiter>(); aimer.m_applyAimToBarrel = false; } else { aimer.m_applyAimToBarrel = true; } if (m_hasTargeter) { Targeter targeter = m_baseObject.AddComponent <Targeter>(); targeter.m_targetTag = m_targetTag; } if (m_hasShooter) { PrefabShooter shooter = m_baseObject.AddComponent <PrefabShooter>(); shooter.m_bulletPrefab = m_bulletPrefab; } Close(); Selection.activeGameObject = m_baseObject; EditorUtility.DisplayDialog("Turret settings applied", "The settings have been applied to your turret!\n" + "Don't forget all settings in the inspector have help that can be " + "viewed by clicking on the little '?' to their right.", "OK"); }
public void OnSceneGUI() { // make sure we detect any changes in the object GUI.changed = false; PrefabShooter shooter = target as PrefabShooter; Aimer aimer = shooter.GetComponent <Aimer>(); if (!aimer || !aimer.m_gunObject) { return; } Matrix4x4 handlesMatrix = Handles.matrix; Handles.matrix = aimer.m_gunObject.transform.localToWorldMatrix; Color oldColor = Handles.color; Handles.color = Color.red; foreach (PrefabShooter.ExitPoint point in shooter.m_exitPoints) { Handles.DrawWireDisc(point.firingOffset, Vector3.forward, 0.2f); point.firingOffset = Handles.PositionHandle(point.firingOffset, Quaternion.identity); } Handles.color = oldColor; Handles.matrix = handlesMatrix; // report any changes in the object. if (GUI.changed) { EditorUtility.SetDirty(shooter); } }