예제 #1
0
        protected override void OnEnable()
        {
            base.OnEnable();

            _slingshot = target as SlingshotComponent;

            _surfaceProperty           = serializedObject.FindProperty(nameof(SlingshotComponent.SlingshotSurface));
            _rubberOffProperty         = serializedObject.FindProperty(nameof(SlingshotComponent.RubberOff));
            _rubberOnProperty          = serializedObject.FindProperty(nameof(SlingshotComponent.RubberOn));
            _coilArmProperty           = serializedObject.FindProperty(nameof(SlingshotComponent.CoilArm));
            _coilArmAngleProperty      = serializedObject.FindProperty(nameof(SlingshotComponent.CoilArmAngle));
            _animationDurationProperty = serializedObject.FindProperty(nameof(SlingshotComponent.AnimationDuration));
            _animationCurveProperty    = serializedObject.FindProperty(nameof(SlingshotComponent.AnimationCurve));
        }
예제 #2
0
        private static void SetupRightSlingshot(GameObject go)
        {
            var playfieldGo = go.GetComponentInParent <PlayfieldComponent>().gameObject;
            var ssParentGo  = GetOrCreateGameObject(playfieldGo, "Slingshots");

            var ssGo = PrefabUtility.InstantiatePrefab(SlingshotComponent.LoadPrefab(), ssParentGo.transform) as GameObject;
            var ss   = ssGo !.GetComponent <SlingshotComponent>();

            ss.name             = "Right Slingshot";
            ss.SlingshotSurface = go.GetComponent <SurfaceColliderComponent>();
            ss.RubberOff        = playfieldGo.transform.Find("Rubbers/RSling").GetComponent <RubberComponent>();
            ss.RubberOn         = playfieldGo.transform.Find("Rubbers/RSling1").GetComponent <RubberComponent>();
            //ss.CoilArm = playfieldGo.transform.Find("Primitives/SLING1").GetComponent<PrimitiveComponent>();

            EditorUtility.SetDirty(ssGo);
            PrefabUtility.RecordPrefabInstancePropertyModifications(ss);

            ss.RebuildMeshes();
        }