コード例 #1
0
 /// <summary>
 /// Displays the linear limit handles.
 /// </summary>
 /// <param name="joint">Joint.</param>
 /// <param name="bindpose">Bindpose.</param>
 /// <returns><see langword="true"/> if the handles changed; otherwise, <see langword="false"/>.</returns>
 public static bool DisplayLinearLimitHandles(Joint joint, Matrix4x4 bindpose)
 {
     if (joint is ConfigurableJoint)
     {
         ConfigurableJoint thisJoint      = joint as ConfigurableJoint;
         float             newLinearLimit = 0f;
         if (SceneGUI.BeginHandles(thisJoint, "Change Linear Limits"))
         {
             newLinearLimit = JointHandles.LinearLimit(thisJoint, bindpose);
         }
         if (SceneGUI.EndHandles())
         {
             SoftJointLimit limit = thisJoint.linearLimit;
             limit.limit           = newLinearLimit;
             thisJoint.linearLimit = limit;
             return(true);
         }
     }
     else if (joint is SpringJoint)
     {
         SpringJoint thisJoint       = joint as SpringJoint;
         Vector2     newLinearLimits = new Vector2(thisJoint.minDistance, thisJoint.maxDistance);
         if (SceneGUI.BeginHandles(thisJoint, "Change Linear Limits"))
         {
             newLinearLimits = JointHandles.SpringLimit(thisJoint, bindpose);
         }
         if (SceneGUI.EndHandles())
         {
             thisJoint.minDistance = newLinearLimits.x;
             thisJoint.maxDistance = newLinearLimits.y;
             return(true);
         }
     }
     return(false);
 }
コード例 #2
0
        /// <summary>
        /// Displays the axis handles.
        /// </summary>
        /// <param name="joint">Joint.</param>
        /// <param name="bindpose">Bindpose.</param>
        /// <returns><see langword="true"/> if the handles changed; otherwise, <see langword="false"/>.</returns>
        public static bool DisplayAxisHandles(Joint joint, Matrix4x4 bindpose)
        {
            bool isChar  = joint is CharacterJoint;
            bool isConf  = joint is ConfigurableJoint;
            bool isHinge = joint is HingeJoint;

            if (!isChar && !isConf && !isHinge)
            {
                return(false);
            }
            bool      result    = false;
            Matrix4x4 oldMatrix = Handles.matrix;

            Handles.matrix = (
                joint.connectedBody == null ? Matrix4x4.identity : joint.connectedBody.transform.localToWorldMatrix
                ) * bindpose;
            Vector3 ax1 = Vector3.forward;
            Vector3 ax2 = Vector3.up;

            if (isChar)
            {
                ax1 = (joint as CharacterJoint).axis;
                ax2 = (joint as CharacterJoint).swingAxis;
            }
            else if (isConf)
            {
                ax1 = (joint as ConfigurableJoint).axis;
                ax2 = (joint as ConfigurableJoint).secondaryAxis;
            }
            else if (isHinge)
            {
                ax1 = (joint as HingeJoint).axis;
            }
            Quaternion axisOrientation = Quaternion.LookRotation(ax1, ax2) * s_BindposeAxisHandleOffset;

            if (SceneGUI.BeginHandles(joint, "Change Axes"))
            {
                axisOrientation = TransformHandles.Rotation(axisOrientation, Vector3.zero);
            }
            if (SceneGUI.EndHandles())
            {
                if (isChar)
                {
                    (joint as CharacterJoint).axis      = axisOrientation * s_PrimaryAxisHandleDirection;
                    (joint as CharacterJoint).swingAxis = axisOrientation * s_SecondaryAxisHandleDirection;
                }
                else if (isConf)
                {
                    (joint as ConfigurableJoint).axis          = axisOrientation * s_PrimaryAxisHandleDirection;
                    (joint as ConfigurableJoint).secondaryAxis = axisOrientation * s_SecondaryAxisHandleDirection;
                }
                else if (isHinge)
                {
                    (joint as HingeJoint).axis = axisOrientation * s_PrimaryAxisHandleDirection;
                }
                result = true;
            }
            Handles.matrix = oldMatrix;
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Displays the scene GUI handles.
        /// </summary>
        protected override void DisplaySceneGUIHandles()
        {
            base.DisplaySceneGUIHandles();
            AnimationCurve newSpeedCurve = null;

            if (
                SceneGUI.BeginHandles(this.Target, "Change Movement Speed Curve") &&
                s_HandleTogglePreference.CurrentValue
                )
            {
                Vector3 up = this.Target.transform.InverseTransformDirection(Vector3.up);
                newSpeedCurve = FalloffHandles.DiscGraph(
                    target.GetHashCode(),
                    this.Target.SpeedCurve,
                    Vector3.zero,
                    Quaternion.LookRotation(Vector3.forward - Vector3.Dot(Vector3.forward, up) * up, up),
                    s_HandleColorPreference.CurrentValue,
                    "Run Speed", "Walk Speed", "Distance", "Speed"
                    );
            }
            if (SceneGUI.EndHandles())
            {
                this.Target.SpeedCurve = newSpeedCurve;
            }
        }
コード例 #4
0
 public void Init()
 {
     // Register to listen to StateManager.StateLoaded event. When fired,
     // call HandleStateLoaded method.
     GameManager.Instance.StateManager.StateLoaded += HandleStateLoaded;
     SceneGUI = FindObjectOfType <SceneGUI>();
 }
コード例 #5
0
 /// <summary>
 /// Displays the joint frame calculation notification message.
 /// </summary>
 public static void DisplayJointFrameCalculationNotification()
 {
     SceneGUI.DisplayNotification(
         "One or more selected joints did not exist before play mode was entered. Handle orientation cannot be determined.",
         s_JointCalculationMessageWrapValues
         );
 }
コード例 #6
0
        /// <summary>
        /// Displays the angular limit handles.
        /// </summary>
        /// <param name="joint">Joint.</param>
        /// <param name="bindpose">Bindpose.</param>
        /// <returns><see langword="true"/> if the handles changed; otherwise, <see langword="false"/>.</returns>
        public static bool DisplayAngularLimitHandles(Joint joint, Matrix4x4 bindpose)
        {
            if (joint == null)
            {
                return(false);
            }
            Matrix4x4 oldMatrix = Handles.matrix;

            Handles.matrix = Matrix4x4.identity;
            bool result = false;

            if (joint is ConfigurableJoint)
            {
                JointAngularLimits newAngularLimits = new JointAngularLimits(joint as ConfigurableJoint);
                if (SceneGUI.BeginHandles(joint, "Change Angular Limits"))
                {
                    newAngularLimits = JointHandles.AngularLimit(
                        joint as ConfigurableJoint, bindpose, AngularLimitHandleSize
                        );
                }
                if (SceneGUI.EndHandles())
                {
                    newAngularLimits.ApplyToJoint(joint as ConfigurableJoint);
                    result = true;
                }
            }
            else if (joint is CharacterJoint)
            {
                JointAngularLimits newAngularLimits = new JointAngularLimits(joint as CharacterJoint);
                if (SceneGUI.BeginHandles(joint, "Change Angular Limits"))
                {
                    newAngularLimits = JointHandles.AngularLimit(
                        joint as CharacterJoint, bindpose, AngularLimitHandleSize
                        );
                }
                if (SceneGUI.EndHandles())
                {
                    newAngularLimits.ApplyToJoint(joint as CharacterJoint);
                    result = true;
                }
            }
            else if (joint is HingeJoint)
            {
                JointLimits newLimits = (joint as HingeJoint).limits;
                if (SceneGUI.BeginHandles(joint, "Change Angular Limits"))
                {
                    newLimits = JointHandles.AngularLimit(
                        joint as HingeJoint, bindpose, AngularLimitHandleSize
                        );
                }
                if (SceneGUI.EndHandles())
                {
                    (joint as HingeJoint).limits = newLimits;
                    result = true;
                }
            }
            Handles.matrix = oldMatrix;
            return(result);
        }
コード例 #7
0
ファイル: SceneManger.cs プロジェクト: firerings/ski-proto-01
 //fade를 이용하여 씬 변경
 public void ChangeSceneOnFadeColor(int scene_idx, Color fade_color, float time)
 {
     this.next_scene_idx = scene_idx;
     this.fade_color = fade_color;
     this.fade_timepersec = 1.0f/time;
     this.scene_update = new SceneUpdate(ColorFadeIn);
     this.scene_gui = new SceneGUI(ColorFadeGUI);
 }
コード例 #8
0
 private void HandleStateLoaded(StateType type)
 {
     SceneGUI = FindObjectOfType <SceneGUI>();
     if (SceneGUI == null)
     {
         Debug.LogWarning("Could not find a SceneGUI component from loaded scene. Is this intentional?");
     }
 }
コード例 #9
0
 private void HandleGameStateChanged(StateType type)
 {
     SceneGUI = FindObjectOfType <SceneGUI> ();
     if (SceneGUI == null)
     {
         Debug.LogWarning("Could not find SceneGUI object from loaded scene. " +
                          "Is this intentional?");
     }
 }
コード例 #10
0
 /// <summary>
 /// Displays the scene GUI handles.
 /// </summary>
 protected override void DisplaySceneGUIHandles()
 {
     base.DisplaySceneGUIHandles();
     // hearing
     if (s_HearingHandleTogglePreference.CurrentValue)
     {
         AnimationCurve newHearing = null;
         Matrix4x4      oldMatrix  = Handles.matrix;
         Handles.matrix = Matrix4x4.identity;
         if (SceneGUI.BeginHandles(this.Target, "Change Hearing Zone"))
         {
             newHearing = FalloffHandles.SphereGraph(
                 target.GetHashCode(),
                 this.Target.HearingFalloff,
                 this.Target.transform.position,
                 s_HearingHandleColorPreference.CurrentValue,
                 "", "", "Distance", "Hearing Falloff"
                 );
         }
         if (SceneGUI.EndHandles())
         {
             this.Target.HearingFalloff = newHearing;
         }
         Handles.matrix = oldMatrix;
     }
     // vision
     if (s_VisionHandleTogglePreference.CurrentValue)
     {
         float newAngle    = this.Target.VisionAngle;
         float newDistance = this.Target.VisionDistance;
         if (SceneGUI.BeginHandles(this.Target, "Change Vision Zone"))
         {
             Color c = Handles.color;
             Handles.color = s_VisionHandleColorPreference.CurrentValue;
             Vector3 up = this.Target.transform.InverseTransformDirection(Vector3.up);
             newAngle = ArcHandles.SolidWedge(
                 target.GetHashCode(),
                 this.Target.VisionAngle,
                 Vector3.zero,
                 Quaternion.LookRotation(Vector3.forward - Vector3.Dot(Vector3.forward, up) * up, up),
                 ref newDistance,
                 string.Format("{0:#} Degrees", this.Target.VisionAngle),
                 string.Format("Vision Distance: {0:#.###}", this.Target.VisionDistance)
                 );
             Handles.color = c;
         }
         if (SceneGUI.EndHandles())
         {
             this.Target.VisionAngle    = newAngle;
             this.Target.VisionDistance = newDistance;
         }
     }
 }
コード例 #11
0
ファイル: StageSelector.cs プロジェクト: 20chan/Gridly
        public StageSelector() : base()
        {
            int init_x = 30, init_y = 40;
            int gap_y = 20, gap_x = 20;
            int width = 200, height = 80;
            var files = new DirectoryInfo("Stages").GetFiles("*.json");
            var iter  = CoordIter();

            btns = new Button[files.Length];
            int i = 0;

            foreach (var file in files)
            {
                var name = Path.GetFileNameWithoutExtension(file.Name);
                iter.MoveNext();
                var coord = iter.Current;
                var b     = new Button(coord.X, coord.Y, width, height, name)
                {
                    ClickStyle = ClickStyle.Popup
                };
                SceneGUI.Add(b);
                btns[i++] = b;
            }
            iter.MoveNext();
            var c = iter.Current;

            editorBtn = new Button(c.X, c.Y, width, height, "+")
            {
                ClickStyle = ClickStyle.Popup
            };
            SceneGUI.Add(editorBtn);

            IEnumerator <Point> CoordIter()
            {
                for (int y = init_y; ; y += height + gap_y)
                {
                    for (int x = 1; x <= 4; x++)
                    {
                        yield return(new Point(init_x + (x - 1) * width + x * gap_x, y));
                    }
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// Displays the scene GUI handles.
        /// </summary>
        protected override void DisplaySceneGUIHandles()
        {
            base.DisplaySceneGUIHandles();
            HashSet <Object> undoObjects = new HashSet <Object>();

            for (int i = 0; i < this.Target.GetLeaves(ref s_Leaves); ++i)
            {
                undoObjects.Add(s_Leaves[i].BackFace);
                undoObjects.Add(s_Leaves[i].FrontFace);
            }
            undoObjects.Remove(null);
            Helix     newHelix  = null;
            Matrix4x4 oldMatrix = Handles.matrix;

            for (int i = 0; i < s_Leaves.Count; ++i)
            {
                if (s_Leaves[i].FrontFace == null || s_Leaves[i].BackFace == null)
                {
                    continue;
                }
                Handles.matrix = s_Leaves[i].FrontFace.transform.localToWorldMatrix;
                if (
                    SceneGUI.BeginHandles(undoObjects.ToArray(), "Modify Plant Leaf") &&
                    HelixMeshRibbonEditor.IsHandleEnabled
                    )
                {
                    newHelix = HelixHandles.MeshRibbon(
                        s_Leaves[i].FrontFace,
                        Vector3.zero,
                        Quaternion.identity,
                        Vector3.one,
                        HelixMeshRibbonEditor.HandleColor
                        );
                }
                if (SceneGUI.EndHandles())
                {
                    s_Leaves[i].FrontFace.Helix = newHelix;
                    s_Leaves[i].BackFace.Helix  = newHelix;
                }
            }
            Handles.matrix = oldMatrix;
        }
コード例 #13
0
        /// <summary>
        /// Displays the scene GUI handles.
        /// </summary>
        protected override void DisplaySceneGUIHandles()
        {
            base.DisplaySceneGUIHandles();
            Helix newHelix = null;

            if (SceneGUI.BeginHandles(target, "Change Helix Mesh Ribbon") && s_HandleTogglePreference.CurrentValue)
            {
                newHelix = HelixHandles.MeshRibbon(
                    this.Target,
                    Vector3.zero,
                    Quaternion.identity,
                    Vector3.one,
                    s_HandleColorPreference.CurrentValue
                    );
            }
            if (SceneGUI.EndHandles())
            {
                this.Target.Helix = newHelix;
            }
        }
コード例 #14
0
        /// <summary>
        /// Displays the anchor handles.
        /// </summary>
        /// <returns>
        /// <see langword="true"/>, if anchor handles was displayed, <see langword="false"/> otherwise.
        /// </returns>
        /// <param name="joint">Joint.</param>
        /// <param name="bindpose">Bindpose.</param>
        /// <returns><see langword="true"/> if the handles changed; otherwise, <see langword="false"/>.</returns>
        public static bool DisplayAnchorHandles(Joint joint, Matrix4x4 bindpose)
        {
            Vector3 anchor = joint.anchor;

            if (SceneGUI.BeginHandles(joint, "Change Anchor"))
            {
                Matrix4x4 oldMatrix = Handles.matrix;
                Handles.matrix = Matrix4x4.TRS(joint.transform.position, joint.transform.rotation, Vector3.one);
                anchor         = TransformHandles.Translation(
                    ObjectX.GenerateHashCode(joint.GetHashCode(), s_AnchorHandleHash), anchor, Quaternion.identity, 0.5f
                    );
                Handles.matrix = oldMatrix;
            }
            if (SceneGUI.EndHandles())
            {
                joint.anchor = anchor;
                return(true);
            }
            return(false);
        }
コード例 #15
0
        public StageEditor() : base()
        {
            statusLabel = new Label(20, 20, "");
            runBtn      = new Button(800, 20, 130, 60, "Run")
            {
                ClickStyle = ClickStyle.Popup
            };
            SceneGUI.Add(runBtn);
            SceneGUI.Add(statusLabel);
            stage = Stage.New(this);

            int i = 0;

            for (; ; i++)
            {
                if (!System.IO.File.Exists($@"Stages\{i}.json"))
                {
                    break;
                }
            }

            path = $@"Stages\{i}.json";
        }
コード例 #16
0
        /// <summary>
        /// Displays the viewport handle.
        /// </summary>
        protected override void DisplaySceneGUIHandles()
        {
            base.DisplaySceneGUIHandles();
            Helix newHelix = null;

            if (
                SceneGUI.BeginHandles(this.Target, "Change Helix Particle Emitter") &&
                s_HandleTogglePreference.CurrentValue
                )
            {
                newHelix = HelixHandles.WireHelix(
                    target.GetHashCode(),
                    this.Target.Helix,
                    Vector3.zero,
                    Quaternion.identity,
                    Vector3.one,
                    s_HandleColorPreference.CurrentValue
                    );
            }
            if (SceneGUI.EndHandles())
            {
                this.Target.Helix = newHelix;
            }
        }
コード例 #17
0
 private void OnEnable()
 {
     GameManager.Instance.StateManager.GameStateChanged +=
         HandleGameStateChanged;
     SceneGUI = FindObjectOfType <SceneGUI> ();
 }
コード例 #18
0
 public void Init()
 {
     // Register to listen to StateManager.StateLoaded event When fird
     GameManager.Instance.StateManager.StateLoaded += HandleStateLoaded;
     SceneGUI = FindObjectOfType <SceneGUI>(); // Find SceneGui component when initialized
 }
コード例 #19
0
ファイル: SceneManger.cs プロジェクト: firerings/ski-proto-01
 private void ColorFadeOut() 
 { 
     this.fade_factor -= Time.unscaledDeltaTime * this.fade_timepersec;
     if(this.fade_factor<=0.0f)
     {
         this.scene_update = null;
         this.scene_gui = null;
         this.fade_factor = 0.0f;
     }
 }
コード例 #20
0
 public StageEditor(string path) : this()
 {
     this.path = path;
     stage     = Stage.Load(this, SerializeHelper.LoadFromFile(path));
     SceneGUI.Add(stage.Visualizer);
 }