public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { base.OnGUI(materialEditor, properties); Material material = materialEditor.target as Material; ProjectorType currentType = ProjectorType.UnityProjector; if (material.IsKeywordEnabled("FSR_RECEIVER")) { currentType = ProjectorType.CustomProjector; } else if (material.IsKeywordEnabled("FSR_PROJECTOR_FOR_LWRP")) { currentType = ProjectorType.ProjectorForLWRP; } float oldLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 150; ProjectorType newType = (ProjectorType)EditorGUILayout.EnumPopup("Projector Type", currentType); EditorGUIUtility.labelWidth = oldLabelWidth; if (newType != currentType) { Undo.RecordObject(material, "Change Projector Type"); string keyword = ProjectorTypeToKeyword(currentType); if (!string.IsNullOrEmpty(keyword)) { material.DisableKeyword(keyword); } keyword = ProjectorTypeToKeyword(newType); if (!string.IsNullOrEmpty(keyword)) { material.EnableKeyword(keyword); } } }
public void Project(ProjectorType type = ProjectorType.none, float angle = -1, float arc = -1, float intensity = -1, float falloff = -1, float speed = -1, float maxDistance = -1) { CircleRadius = 0; Intensity = (intensity < 0)? InitialIntensity : intensity; IntensityFallOff = (falloff < 0) ? IntensityFallOff : falloff; ProjectionRate = (speed < 0) ? ProjectionRate : speed; CircleTargetRadius = (maxDistance < 0)? MaxRadius : maxDistance; myType = (type == ProjectorType.none) ? myType : type; myAngle = (angle < 0) ? myAngle : angle; myArc = (arc < 0) ? myArc : arc; }
static private string ProjectorTypeToKeyword(ProjectorType type) { switch (type) { case ProjectorType.CustomProjector: return("FSR_RECEIVER"); case ProjectorType.ProjectorForLWRP: return("FSR_PROJECTOR_FOR_LWRP"); case ProjectorType.UnityProjector: return(""); } return(null); }
/// <summary> ///切换投影方式 ///调用StartView_LR(...)后,可切换到只显示左画面到投屏窗口或左右一起显示 /// ----------- ---------- /// | L | R | or | L | /// ----------- ---------- ///如果只调用StartView(...),则此函数无效 /// </summary> /// <param name="type">目标投屏方式</param> public static void SwitchProjector(ProjectorType type) { fmARSwitchProjector((int)type); }