示例#1
0
 private void Awake()
 {
     handleDefinition = this.GetComponentInParent <HandleDefinition>();
     if (handleDefinition == null)
     {
         Debug.LogError("No HandleDefinition found for HandleOrientation " + this.name);
     }
 }
示例#2
0
        public override void OnInspectorGUI()
        {
            script = handle = (HandleDefinition)target;
            ItemDefinition item = handle.transform.GetComponentInParent <ItemDefinition>();

            PointToPointButton(handle.axisLength);

            base.OnInspectorGUI();

            if (GUILayout.Button("Calculate Reach") && item)
            {
                handle.CalculateReach();
            }

            if (GUILayout.Button("Update to new orientations") && item)
            {
                handle.CheckOrientations();
            }

            if (handle.allowedOrientations.Count > 0)
            {
                EditorGUILayout.HelpBox("The allowed orientations list is obsolete, Use child HandleOrientation instead.", MessageType.Warning);
            }

            if (handle.transform.localScale != Vector3.one)
            {
                EditorGUILayout.HelpBox("Handle object scale must be set to 1.", MessageType.Error);
            }

            if (handle.axisLength < 0)
            {
                EditorGUILayout.HelpBox("Handle axis length must be a positive number or zero.", MessageType.Error);
            }

            if (handle.touchRadius <= 0)
            {
                EditorGUILayout.HelpBox("Handle touch radius must be a positive number.", MessageType.Error);
            }

            if (handle.reach <= 0)
            {
                EditorGUILayout.HelpBox("Handle reach must be a positive number.", MessageType.Error);
            }

            if (handle.slideToHandleOffset <= 0)
            {
                EditorGUILayout.HelpBox("Slide to handle offset must be a positive number.", MessageType.Error);
            }
        }
示例#3
0
        public virtual void OnValidate()
        {
            if (!Application.isPlaying)
            {
                if (Application.isEditor)
                {
                    UnityEngine.Object[] asset = Resources.LoadAll("Hand");
                    for (int i = 0; i < asset.Length; i++)
                    {
                        if (asset[i] is Mesh)
                        {
                            handMesh = asset[i] as Mesh;
                        }
                    }
                }

                handleDefinition = this.GetComponentInParent <HandleDefinition>();
                UpdateName();
            }
        }
示例#4
0
        protected virtual void OnValidate()
        {
            if (!this.gameObject.activeInHierarchy)
            {
                return;
            }
            holderPoint = this.transform.Find("HolderPoint");
            if (!holderPoint)
            {
                holderPoint = new GameObject("HolderPoint").transform;
                holderPoint.SetParent(this.transform, false);
            }
            parryPoint = this.transform.Find("ParryPoint");
            if (!parryPoint)
            {
                parryPoint = new GameObject("ParryPoint").transform;
                parryPoint.SetParent(this.transform, false);
            }
            preview = this.GetComponentInChildren <Preview>();
            if (!preview && this.transform.Find("Preview"))
            {
                preview = this.transform.Find("Preview").gameObject.AddComponent <Preview>();
            }
            if (!preview)
            {
                preview = new GameObject("Preview").AddComponent <Preview>();
                preview.transform.SetParent(this.transform, false);
            }
            Transform whoosh = this.transform.Find("Whoosh");

            if (whoosh && !whoosh.GetComponent <WhooshPoint>())
            {
                whoosh.gameObject.AddComponent <WhooshPoint>();
            }

            if (!mainHandleRight)
            {
                foreach (HandleDefinition handleDefinition in this.GetComponentsInChildren <HandleDefinition>())
                {
                    if (handleDefinition.IsAllowed(Side.Right))
                    {
                        mainHandleRight = handleDefinition;
                        break;
                    }
                }
            }
            if (!mainHandleLeft)
            {
                foreach (HandleDefinition handleDefinition in this.GetComponentsInChildren <HandleDefinition>())
                {
                    if (handleDefinition.IsAllowed(Side.Left))
                    {
                        mainHandleLeft = handleDefinition;
                        break;
                    }
                }
            }
            if (!mainHandleRight)
            {
                mainHandleRight = this.GetComponentInChildren <HandleDefinition>();
            }
            if (useCustomCenterOfMass)
            {
                this.GetComponent <Rigidbody>().centerOfMass = customCenterOfMass;
            }
            else
            {
                this.GetComponent <Rigidbody>().ResetCenterOfMass();
            }
            if (customInertiaTensor)
            {
                if (customInertiaTensorCollider == null)
                {
                    customInertiaTensorCollider = new GameObject("InertiaTensorCollider").AddComponent <CapsuleCollider>();
                    customInertiaTensorCollider.transform.SetParent(this.transform, false);
                    customInertiaTensorCollider.radius    = 0.05f;
                    customInertiaTensorCollider.direction = 2;
                }
                customInertiaTensorCollider.enabled          = false;
                customInertiaTensorCollider.isTrigger        = true;
                customInertiaTensorCollider.gameObject.layer = 2;
            }
        }
示例#5
0
 private void OnSceneGUI()
 {
     script = handle = (HandleDefinition)target;
     UpdatePoints(ref handle.axisLength);
 }
示例#6
0
 private void OnEnable()
 {
     script = handle = (HandleDefinition)target;
     ResetPoints(handle.axisLength);
 }